pub struct FileSize { /* private fields */ }Expand description
A file size representation that can be zero
一个可以表示零的文件大小结构体。
Implementations§
Source§impl FileSize
impl FileSize
Sourcepub const fn new(bytes: u64) -> Self
pub const fn new(bytes: u64) -> Self
Create a new FileSize instance from bytes
从字节数创建一个新的 FileSize 实例
Sourcepub fn to_nonzero(&self) -> Option<NonZeroFileSize>
pub fn to_nonzero(&self) -> Option<NonZeroFileSize>
Convert to NonZeroFileSize if the value is not zero
如果值不为零,则转换为 NonZeroFileSize
Trait Implementations§
Source§impl AddAssign for FileSize
impl AddAssign for FileSize
Source§fn add_assign(&mut self, rhs: Self)
fn add_assign(&mut self, rhs: Self)
Performs the
+= operation. Read moreSource§impl DivAssign<u64> for FileSize
impl DivAssign<u64> for FileSize
Source§fn div_assign(&mut self, rhs: u64)
fn div_assign(&mut self, rhs: u64)
Performs the
/= operation. Read moreSource§impl FileSizeFormat for FileSize
impl FileSizeFormat for FileSize
Source§fn get_si_parts(&self) -> (String, &'static str)
fn get_si_parts(&self) -> (String, &'static str)
Returns the formatted value and unit in SI (base-1000) standard
The formatted_value is returned as String to ensure correct decimal places (e.g., “1.00”)
返回 SI (base-1000) 标准的 (formatted_value, unit)
formatted_value 作为 String 返回,以保证正确的小数位数 (例如 “1.00”)
Source§fn get_iec_parts(&self) -> (String, &'static str)
fn get_iec_parts(&self) -> (String, &'static str)
Returns the formatted value and unit in IEC (base-1024) standard
The formatted_value is returned as String to ensure correct decimal places (e.g., “1.00”)
返回 IEC (base-1024) 标准的 (formatted_value, unit)
formatted_value 作为 String 返回,以保证正确的小数位数 (例如 “1.00”)
Source§fn to_si_string(&self) -> String
fn to_si_string(&self) -> String
Returns a formatted string in SI (base-1000) standard Read more
Source§fn to_iec_string(&self) -> String
fn to_iec_string(&self) -> String
Returns a formatted string in IEC (base-1024) standard Read more
fn to_formatted(self, standard: SizeStandard) -> FormattedValue<Self>
Source§impl From<NonZeroFileSize> for FileSize
impl From<NonZeroFileSize> for FileSize
Source§fn from(size: NonZeroFileSize) -> Self
fn from(size: NonZeroFileSize) -> Self
Converts to this type from the input type.
Source§impl MulAssign<u64> for FileSize
impl MulAssign<u64> for FileSize
Source§fn mul_assign(&mut self, rhs: u64)
fn mul_assign(&mut self, rhs: u64)
Performs the
*= operation. Read moreSource§impl Ord for FileSize
impl Ord for FileSize
Source§impl PartialOrd for FileSize
impl PartialOrd for FileSize
Source§impl SubAssign for FileSize
impl SubAssign for FileSize
Source§fn sub_assign(&mut self, rhs: Self)
fn sub_assign(&mut self, rhs: Self)
Performs the
-= operation. Read moreSource§impl TryFrom<FileSize> for NonZeroFileSize
impl TryFrom<FileSize> for NonZeroFileSize
impl Copy for FileSize
impl Eq for FileSize
impl StructuralPartialEq for FileSize
Auto Trait Implementations§
impl Freeze for FileSize
impl RefUnwindSafe for FileSize
impl Send for FileSize
impl Sync for FileSize
impl Unpin for FileSize
impl UnwindSafe for FileSize
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