use core::str::FromStr;
use super::{AdjustedByte, Byte, Unit, UnitType};
use crate::ParseError;
impl From<Byte> for AdjustedByte {
#[inline]
fn from(value: Byte) -> Self {
value.get_appropriate_unit(UnitType::Both)
}
}
impl From<AdjustedByte> for f64 {
#[inline]
fn from(value: AdjustedByte) -> Self {
value.get_value()
}
}
impl From<AdjustedByte> for Unit {
#[inline]
fn from(value: AdjustedByte) -> Self {
value.get_unit()
}
}
impl From<AdjustedByte> for Byte {
#[inline]
fn from(value: AdjustedByte) -> Self {
value.get_byte()
}
}
impl FromStr for AdjustedByte {
type Err = ParseError;
#[inline]
fn from_str(s: &str) -> Result<Self, Self::Err> {
Ok(Byte::parse_str(s, false)?.get_appropriate_unit(UnitType::Both))
}
}