byte_unit/byte/adjusted/
built_in_traits.rs1use core::str::FromStr;
2
3use super::{AdjustedByte, Byte, Unit, UnitType};
4use crate::ParseError;
5
6impl From<Byte> for AdjustedByte {
7 #[inline]
9 fn from(value: Byte) -> Self {
10 value.get_appropriate_unit(UnitType::Both)
11 }
12}
13
14impl From<AdjustedByte> for f64 {
15 #[inline]
16 fn from(value: AdjustedByte) -> Self {
17 value.get_value()
18 }
19}
20
21impl From<AdjustedByte> for Unit {
22 #[inline]
23 fn from(value: AdjustedByte) -> Self {
24 value.get_unit()
25 }
26}
27
28impl From<AdjustedByte> for Byte {
29 #[inline]
30 fn from(value: AdjustedByte) -> Self {
31 value.get_byte()
32 }
33}
34
35impl FromStr for AdjustedByte {
36 type Err = ParseError;
37
38 #[inline]
41 fn from_str(s: &str) -> Result<Self, Self::Err> {
42 Ok(Byte::parse_str(s, false)?.get_appropriate_unit(UnitType::Both))
43 }
44}