pub enum Size {
B(usize),
KB(usize),
MB(usize),
GB(usize),
}Expand description
Memory size representation supporting common units.
This enum provides a convenient way to specify memory sizes in bytes, kilobytes, megabytes, or gigabytes. All units use binary (base-2) multipliers (1 KB = 1024 bytes).
§Examples
use swage_core::util::Size;
let size = Size::MB(4);
assert_eq!(size.bytes(), 4 * 1024 * 1024);
let small = Size::KB(8);
assert_eq!(small.bytes(), 8192);
let large = Size::GB(2);
assert_eq!(large.bytes(), 2 * (1 << 30));Variants§
B(usize)
Size in bytes
KB(usize)
Size in kilobytes (1 KB = 1024 bytes)
MB(usize)
Size in megabytes (1 MB = 1024 KB)
GB(usize)
Size in gigabytes (1 GB = 1024 MB)
Implementations§
Trait Implementations§
impl Copy for Size
Auto Trait Implementations§
impl Freeze for Size
impl RefUnwindSafe for Size
impl Send for Size
impl Sync for Size
impl Unpin for Size
impl UnwindSafe for Size
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more