pub struct File { /* private fields */ }
Implementations§
source§impl File
impl File
sourcepub fn read(path: impl AsRef<Path> + Into<PathBuf>) -> Result<Arc<Self>, Error>
pub fn read(path: impl AsRef<Path> + Into<PathBuf>) -> Result<Arc<Self>, Error>
Read a file.
Example
let file = File::read("Cargo.toml").unwrap();
assert!(file.to_utf8_lossy().starts_with("# https://doc.rust-lang.org/cargo/reference/manifest.html"));
pub fn name(&self) -> &OsStr
pub fn path(&self) -> &Path
pub fn metadata(&self) -> &Metadata
pub fn as_bytes(&self) -> &[u8] ⓘ
pub fn to_utf8(&self) -> Result<&str, Utf8Error>
pub fn to_utf8_lossy(&self) -> Cow<'_, str>
Trait Implementations§
Auto Trait Implementations§
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