pub struct File { /* private fields */ }
Expand description
Represents a file, which may be embedded or from the filesystem. Provides methods to access file contents and metadata.
Implementations§
Source§impl File
impl File
Sourcepub fn extension(&self) -> Option<&str>
pub fn extension(&self) -> Option<&str>
Returns the file extension as a string slice, if available.
Sourcepub fn absolute_path(&self) -> &Path
pub fn absolute_path(&self) -> &Path
Returns the absolute path of this file.
Sourcepub fn is_embedded(&self) -> bool
pub fn is_embedded(&self) -> bool
Returns true if this file is embedded in the binary.
Sourcepub fn read_bytes(&self) -> Result<Vec<u8>>
pub fn read_bytes(&self) -> Result<Vec<u8>>
Reads the file contents as bytes.
Sourcepub fn read_str(&self) -> Result<String>
pub fn read_str(&self) -> Result<String>
Reads the file contents as a UTF-8 string. Returns an error if the contents are not valid UTF-8.
Sourcepub fn metadata(&self) -> Result<FileMetaData>
pub fn metadata(&self) -> Result<FileMetaData>
Returns the metadata for this file, such as modification time and size.
Trait Implementations§
impl Eq for File
impl StructuralPartialEq for File
Auto Trait Implementations§
impl Freeze for File
impl RefUnwindSafe for File
impl Send for File
impl Sync for File
impl Unpin for File
impl UnwindSafe for File
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