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 sync_file<P>(&self, path: P) -> Result<()>
where
P: AsRef<Path> + Send + 'static; fn file_size(&self, file: &Self::File) -> Result<u64>; 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 sync_file<P>(&self, path: P) -> Result<()> where
P: AsRef<Path> + Send + 'static,
P: AsRef<Path> + Send + 'static,
Sync the file.
fn file_size(&self, file: &Self::File) -> Result<u64>
Get the size of the file in bytes.
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.
Implementations on Foreign Types
impl<'a, F> FileSystem for &'a F where
F: FileSystem,
[src]
F: FileSystem,
type File = F::File
fn open_file<P>(&self, path: P) -> Result<Self::File> where
P: AsRef<Path> + Send + 'static,
[src]
P: AsRef<Path> + Send + 'static,
fn sync_file<P>(&self, path: P) -> Result<()> where
P: AsRef<Path> + Send + 'static,
[src]
P: AsRef<Path> + Send + 'static,
fn file_size(&self, file: &Self::File) -> Result<u64>
[src]
fn read_file(
&self,
file: &mut Self::File,
offset: u64,
buffer: &mut [u8]
) -> Result<usize>
[src]
&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>
[src]
&self,
file: &mut Self::File,
offset: u64,
buffer: &[u8]
) -> Result<usize>
Implementors
impl<F> FileSystem for FileHandleCache<F> where
F: FileSystem, type File = Arc<Mutex<F::File>>;impl FileSystem for NativeFileSystem type File = NativeFile;