pub struct ByteSize(/* private fields */);Implementations§
source§impl ByteSize
impl ByteSize
sourcepub fn of(value: impl Into<Float>, unit: Unit) -> Self
pub fn of(value: impl Into<Float>, unit: Unit) -> Self
Create a ByteSize from a value and unit
use xbytes::prelude::*;
let size = ByteSize::of(10, MEBI_BYTE);
assert_eq!(size.to_string(), "10 MiB");
let a = ByteSize::of(1.2, GIGA_BYTE);
let b = ByteSize::of(1.3, GIGA_BYTE);
assert_eq!((a + b).repr(Mode::Decimal).to_string(), "2.50 GB");pub const fn from_bytes(value: Int) -> Self
pub const fn from_bits(value: Int) -> Result<Self, ParseError>
pub const fn bytes(&self) -> Int
pub const fn bits(&self) -> Result<Int, ParseError>
pub fn repr(&self, mode: Mode) -> ByteSizeRepr
pub fn repr_as(&self, unit: impl Into<Unit>) -> ByteSizeRepr
Trait Implementations§
source§impl AddAssign for ByteSize
impl AddAssign for ByteSize
source§fn add_assign(&mut self, rhs: Self)
fn add_assign(&mut self, rhs: Self)
Performs the
+= operation. Read moresource§impl<T: TryInto<Int>> DivAssign<T> for ByteSize
impl<T: TryInto<Int>> DivAssign<T> for ByteSize
source§fn div_assign(&mut self, rhs: T)
fn div_assign(&mut self, rhs: T)
Performs the
/= operation. Read moresource§impl From<ByteSizeRepr> for ByteSize
impl From<ByteSizeRepr> for ByteSize
source§fn from(repr: ByteSizeRepr) -> Self
fn from(repr: ByteSizeRepr) -> Self
Converts to this type from the input type.
source§impl<T: TryInto<Int>> MulAssign<T> for ByteSize
impl<T: TryInto<Int>> MulAssign<T> for ByteSize
source§fn mul_assign(&mut self, rhs: T)
fn mul_assign(&mut self, rhs: T)
Performs the
*= operation. Read moresource§impl Ord for ByteSize
impl Ord for ByteSize
source§impl PartialEq for ByteSize
impl PartialEq for ByteSize
source§impl PartialOrd for ByteSize
impl PartialOrd for ByteSize
1.0.0 · source§fn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
This method tests less than or equal to (for
self and other) and is used by the <=
operator. Read moresource§impl SubAssign for ByteSize
impl SubAssign for ByteSize
source§fn sub_assign(&mut self, rhs: Self)
fn sub_assign(&mut self, rhs: Self)
Performs the
-= operation. Read moreimpl Copy for ByteSize
impl Eq for ByteSize
impl StructuralEq for ByteSize
impl StructuralPartialEq for ByteSize
Auto Trait Implementations§
impl RefUnwindSafe for ByteSize
impl Send for ByteSize
impl Sync for ByteSize
impl Unpin for ByteSize
impl UnwindSafe for ByteSize
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more