Skip to main content

FileMetadata

Struct FileMetadata 

Source
pub struct FileMetadata {
Show 19 fields pub created: String, pub modified: String, pub accessed: String, pub size_in_bytes: u64, pub is_file_read_only: bool, pub is_dir: bool, pub is_file: bool, pub is_symlink: bool, pub is_readable: bool, pub is_writable: bool, pub is_executable: bool, pub dev: u64, pub ino: u64, pub mode: u32, pub nlink: u64, pub uid: u32, pub gid: u32, pub blksize: u64, pub blocks: u64, /* private fields */
}

Fields§

§created: String§modified: String§accessed: String§size_in_bytes: u64§is_file_read_only: bool§is_dir: bool§is_file: bool§is_symlink: bool§is_readable: bool§is_writable: bool§is_executable: bool§dev: u64§ino: u64§mode: u32§nlink: u64§uid: u32§gid: u32§blksize: u64§blocks: u64

Implementations§

Source§

impl FileMetadata

Methods for FileMetadata, providing functionality to create a new instance from a file path, retrieve file metadata, and access file size information.

§Fields

§Cross-platform
  • created, modified, accessed — date strings (YYYY-MM-DD)
  • size_in_bytes — raw file size in bytes
  • is_file_read_only, is_dir, is_file, is_symlink — file type flags
  • is_readable, is_writable, is_executable — permission checks
§Unix only (#[cfg(unix)])
  • dev — device ID
  • ino — inode number
  • mode — full permission bits (octal)
  • nlink — hard link count
  • uid, gid — owner/group IDs
  • blksize, blocks — filesystem block size and allocated 512-byte blocks
§Windows only (#[cfg(windows)])
  • file_attributes — Windows attribute flags (hidden, system, archive, etc.)
  • creation_time, last_write_time, last_access_time — raw FILETIME values

§Methods

  • new(path: &Path) -> Result<Self, String> — construct from a file path
  • readable(&self) -> bool — whether the file is readable
  • writable(&self) -> bool — whether the file is writable
  • executable(&self) -> bool — whether the file is executable
  • get_file_in_kilobytes(&self) -> f32 — file size in KB
  • get_file_in_megabytes(&self) -> f32 — file size in MB
  • get_file_in_gigabytes(&self) -> f32 — file size in GB
  • get_file_in_terabytes(&self) -> f32 — file size in TB
Source

pub fn new(path: &Path) -> Result<Self, String>

Source

pub fn readable(&self) -> bool

Source

pub fn writable(&self) -> bool

Source

pub fn executable(&self) -> bool

Source

pub fn get_file_in_kilobytes(&self) -> f32

Source

pub fn get_file_in_megabytes(&self) -> f32

Source

pub fn get_file_in_gigabytes(&self) -> f32

Source

pub fn get_file_in_terabytes(&self) -> f32

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.