pub struct Size(/* private fields */);
Expand description
Type-safe wrapper for size values in file system operations.
Size
represents sizes, lengths, and byte counts as a 64-bit unsigned integer.
This provides a range of 0 to approximately 18 exabytes, which is sufficient for
any practical file system operation. The type provides various conversion methods
and arithmetic operations for convenient size manipulation.
§Examples
use file_system::Size;
// Create a size representing 1024 bytes
let size = Size::new(1024);
assert_eq!(size.As_u64(), 1024);
// Convert from usize
let size_from_usize: Size = 512usize.into();
assert_eq!(size_from_usize.As_u64(), 512);
// Arithmetic operations
let total = size + size_from_usize;
assert_eq!(total.As_u64(), 1536);
§Type Safety
Using Size
instead of raw integers helps prevent mixing up different
numeric types and provides clearer API signatures throughout the file system.
Implementations§
Trait Implementations§
Source§impl AddAssign<Size> for usize
impl AddAssign<Size> for usize
Source§fn add_assign(&mut self, rhs: Size)
fn add_assign(&mut self, rhs: Size)
Performs the
+=
operation. Read moreSource§impl AddAssign<u64> for Size
impl AddAssign<u64> for Size
Source§fn add_assign(&mut self, rhs: u64)
fn add_assign(&mut self, rhs: u64)
Performs the
+=
operation. Read moreSource§impl AddAssign<usize> for Size
impl AddAssign<usize> for Size
Source§fn add_assign(&mut self, rhs: usize)
fn add_assign(&mut self, rhs: usize)
Performs the
+=
operation. Read moreSource§impl AddAssign for Size
impl AddAssign for Size
Source§fn add_assign(&mut self, rhs: Size)
fn add_assign(&mut self, rhs: Size)
Performs the
+=
operation. Read moreSource§impl Ord for Size
impl Ord for Size
Source§impl PartialOrd for Size
impl PartialOrd for Size
impl Copy for Size
impl Eq for Size
impl StructuralPartialEq 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