pub struct File { /* private fields */ }
Implementations
sourceimpl 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]ⓘNotable traits for &'_ [u8]impl<'_> Read for &'_ [u8]impl<'_> Write for &'_ mut [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
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcepub fn borrow_mut(&mut self) -> &mut T
pub fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more