pub struct File(/* private fields */);Expand description
an open file (closed when dropped): an OS file, or a stream of a vfs mount
Implementations§
Source§impl File
impl File
Sourcepub fn open(path: &str, mode: u32) -> Option<File>
pub fn open(path: &str, mode: u32) -> Option<File>
FO_READ (existing, read only), FO_WRITE (create / truncate), FO_RW (open or create); on every mount (vfs.rs)
Sourcepub fn create_new(path: &str) -> Option<File>
pub fn create_new(path: &str) -> Option<File>
Create a named file exclusively; never open an existing path (a mount without OS files: exclusive inside this process).
Sourcepub fn open_temp(dir: Option<&str>) -> Option<File>
pub fn open_temp(dir: Option<&str>) -> Option<File>
a new file without a lasting name in dir (None = temp_dir) that disappears when it is closed (also after a crash); a mount without OS files: a file in memory [plat_file_open_temp]
Sourcepub fn read_at(&self, off: u64, buf: &mut [u8]) -> Option<usize>
pub fn read_at(&self, off: u64, buf: &mut [u8]) -> Option<usize>
bytes read at off (fewer at the end of the file), None on an error before any byte
Sourcepub fn write_at(&self, off: u64, buf: &[u8]) -> Option<usize>
pub fn write_at(&self, off: u64, buf: &[u8]) -> Option<usize>
bytes written at off (the file grows as needed), None on an error before any byte
pub fn size(&self) -> Option<u64>
Trait Implementations§
Source§impl Stream for File
impl Stream for File
Auto Trait Implementations§
impl !RefUnwindSafe for File
impl !UnwindSafe for File
impl Forget for File
impl Freeze for File
impl Send for File
impl Sync for File
impl Unpin for File
impl UnsafeUnpin 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