Trait bip_disk::FileSystem
[−]
[src]
pub trait FileSystem { type File; fn open_file<P>(&self, path: P) -> Result<Self::File>
where
P: AsRef<Path> + Send + 'static; fn file_size(&self, file: &Self::File) -> Result<u64>; fn remove_file(&self, file: Self::File) -> Result<()>; fn read_file(
&self,
file: &mut Self::File,
offset: u64,
buffer: &mut [u8]
) -> Result<usize>; fn write_file(
&self,
file: &mut Self::File,
offset: u64,
buffer: &[u8]
) -> Result<usize>; }
Trait for performing operations on some file system.
Relative paths will originate from an implementation defined directory.
Associated Types
type File
Some file object.
Required Methods
fn open_file<P>(&self, path: P) -> Result<Self::File> where
P: AsRef<Path> + Send + 'static,
P: AsRef<Path> + Send + 'static,
Open a file, create it if it does not exist.
Intermediate directories will be created if necessary.
fn file_size(&self, file: &Self::File) -> Result<u64>
Get the size of the file in bytes.
fn remove_file(&self, file: Self::File) -> Result<()>
Remove a given file from the file system.
fn read_file(
&self,
file: &mut Self::File,
offset: u64,
buffer: &mut [u8]
) -> Result<usize>
&self,
file: &mut Self::File,
offset: u64,
buffer: &mut [u8]
) -> Result<usize>
Read the contents of the file at the given offset.
On success, return the number of bytes read.
fn write_file(
&self,
file: &mut Self::File,
offset: u64,
buffer: &[u8]
) -> Result<usize>
&self,
file: &mut Self::File,
offset: u64,
buffer: &[u8]
) -> Result<usize>
Write the contents of the file at the given offset.
On success, return the number of bytes written. If offset is past the current size of the file, zeroes will be filled in.
Implementors
impl FileSystem for NativeFileSystem
impl<'a, F> FileSystem for &'a F where
F: FileSystem,