Struct embedded_sdmmc::File
source · pub struct File<'a, D, T, const MAX_DIRS: usize, const MAX_FILES: usize, const MAX_VOLUMES: usize>where
D: BlockDevice,
T: TimeSource,{ /* private fields */ }
Expand description
Represents an open file on disk.
If you drop a value of this type, it closes the file automatically. However,
it holds a mutable reference to its parent VolumeManager
, which restricts
which operations you can perform.
Implementations§
source§impl<'a, D, T, const MAX_DIRS: usize, const MAX_FILES: usize, const MAX_VOLUMES: usize> File<'a, D, T, MAX_DIRS, MAX_FILES, MAX_VOLUMES>where
D: BlockDevice,
T: TimeSource,
impl<'a, D, T, const MAX_DIRS: usize, const MAX_FILES: usize, const MAX_VOLUMES: usize> File<'a, D, T, MAX_DIRS, MAX_FILES, MAX_VOLUMES>where
D: BlockDevice,
T: TimeSource,
sourcepub fn new(
raw_file: RawFile,
volume_mgr: &'a mut VolumeManager<D, T, MAX_DIRS, MAX_FILES, MAX_VOLUMES>
) -> File<'a, D, T, MAX_DIRS, MAX_FILES, MAX_VOLUMES>
pub fn new( raw_file: RawFile, volume_mgr: &'a mut VolumeManager<D, T, MAX_DIRS, MAX_FILES, MAX_VOLUMES> ) -> File<'a, D, T, MAX_DIRS, MAX_FILES, MAX_VOLUMES>
Create a new File
from a RawFile
sourcepub fn read(&mut self, buffer: &mut [u8]) -> Result<usize, Error<D::Error>>
pub fn read(&mut self, buffer: &mut [u8]) -> Result<usize, Error<D::Error>>
Read from the file
Returns how many bytes were read, or an error.
sourcepub fn seek_from_current(&mut self, offset: i32) -> Result<(), Error<D::Error>>
pub fn seek_from_current(&mut self, offset: i32) -> Result<(), Error<D::Error>>
Seek a file with an offset from the current position.
sourcepub fn seek_from_start(&mut self, offset: u32) -> Result<(), Error<D::Error>>
pub fn seek_from_start(&mut self, offset: u32) -> Result<(), Error<D::Error>>
Seek a file with an offset from the start of the file.
sourcepub fn seek_from_end(&mut self, offset: u32) -> Result<(), Error<D::Error>>
pub fn seek_from_end(&mut self, offset: u32) -> Result<(), Error<D::Error>>
Seek a file with an offset back from the end of the file.
sourcepub fn to_raw_file(self) -> RawFile
pub fn to_raw_file(self) -> RawFile
Convert back to a raw file
Trait Implementations§
source§impl<'a, D, T, const MAX_DIRS: usize, const MAX_FILES: usize, const MAX_VOLUMES: usize> Debug for File<'a, D, T, MAX_DIRS, MAX_FILES, MAX_VOLUMES>where
D: BlockDevice,
T: TimeSource,
impl<'a, D, T, const MAX_DIRS: usize, const MAX_FILES: usize, const MAX_VOLUMES: usize> Debug for File<'a, D, T, MAX_DIRS, MAX_FILES, MAX_VOLUMES>where
D: BlockDevice,
T: TimeSource,
Auto Trait Implementations§
impl<'a, D, T, const MAX_DIRS: usize, const MAX_FILES: usize, const MAX_VOLUMES: usize> RefUnwindSafe for File<'a, D, T, MAX_DIRS, MAX_FILES, MAX_VOLUMES>where
D: RefUnwindSafe,
T: RefUnwindSafe,
impl<'a, D, T, const MAX_DIRS: usize, const MAX_FILES: usize, const MAX_VOLUMES: usize> Send for File<'a, D, T, MAX_DIRS, MAX_FILES, MAX_VOLUMES>
impl<'a, D, T, const MAX_DIRS: usize, const MAX_FILES: usize, const MAX_VOLUMES: usize> Sync for File<'a, D, T, MAX_DIRS, MAX_FILES, MAX_VOLUMES>
impl<'a, D, T, const MAX_DIRS: usize, const MAX_FILES: usize, const MAX_VOLUMES: usize> Unpin for File<'a, D, T, MAX_DIRS, MAX_FILES, MAX_VOLUMES>
impl<'a, D, T, const MAX_DIRS: usize, const MAX_FILES: usize, const MAX_VOLUMES: usize> !UnwindSafe for File<'a, D, T, MAX_DIRS, MAX_FILES, MAX_VOLUMES>
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