Storage

Trait Storage 

Source
pub trait Storage {
Show 26 methods // Required methods fn root_node(&self) -> Node; fn get_version(&self) -> u32; fn new_node(&mut self) -> Node; fn mount_node( &mut self, node: Node, memory: Box<dyn Memory>, mount_policy: MountedFileSizePolicy, ) -> Result<(), Error>; fn unmount_node(&mut self, node: Node) -> Result<Box<dyn Memory>, Error>; fn is_mounted(&self, node: Node) -> bool; fn get_mounted_memory(&self, node: Node) -> Option<&dyn Memory>; fn init_mounted_memory(&mut self, node: Node) -> Result<(), Error>; fn store_mounted_memory(&mut self, node: Node) -> Result<(), Error>; fn get_metadata(&self, node: Node) -> Result<Metadata, Error>; fn put_metadata( &mut self, node: Node, metadata: &Metadata, ) -> Result<(), Error>; fn get_direntry( &self, node: Node, index: DirEntryIndex, ) -> Result<DirEntry, Error>; fn get_direntry_index_by_name( &self, el: &(Node, FileName), ) -> Option<DirEntryIndex>; fn with_direntries( &self, node: Node, initial_index: Option<DirEntryIndex>, f: &mut dyn FnMut(&DirEntryIndex, &DirEntry) -> bool, ); fn new_direntry_index(&self, node: Node) -> DirEntryIndex; fn put_direntry( &mut self, node: Node, index: DirEntryIndex, entry: DirEntry, ); fn rm_direntry(&mut self, node: Node, index: DirEntryIndex); fn read( &mut self, node: Node, read_offset: FileSize, buf: &mut [u8], ) -> Result<FileSize, Error>; fn write( &mut self, node: Node, offset: FileSize, buf: &[u8], ) -> Result<FileSize, Error>; fn resize_file( &mut self, node: Node, new_size: FileSize, ) -> Result<(), Error>; fn rm_file(&mut self, node: Node) -> Result<(), Error>; fn set_chunk_size(&mut self, chunk_size: ChunkSize) -> Result<(), Error>; fn chunk_size(&self) -> usize; fn set_chunk_type(&mut self, chunk_type: ChunkType); fn chunk_type(&self) -> ChunkType; fn flush(&mut self, node: Node);
}
Expand description

Abstraction of the underlying storage layer.

Required Methods§

Source

fn root_node(&self) -> Node

Get the root node ID of the storage.

Source

fn get_version(&self) -> u32

Get version of the file system.

Source

fn new_node(&mut self) -> Node

Generate the next available node ID.

Source

fn mount_node( &mut self, node: Node, memory: Box<dyn Memory>, mount_policy: MountedFileSizePolicy, ) -> Result<(), Error>

mark node as mounted.

Source

fn unmount_node(&mut self, node: Node) -> Result<Box<dyn Memory>, Error>

mark note as not mounted.

Source

fn is_mounted(&self, node: Node) -> bool

return true if the node is mounted.

Source

fn get_mounted_memory(&self, node: Node) -> Option<&dyn Memory>

return mounted memory related to the node, or None.

Source

fn init_mounted_memory(&mut self, node: Node) -> Result<(), Error>

initialize memory with the contents from file.

Source

fn store_mounted_memory(&mut self, node: Node) -> Result<(), Error>

store mounted memory state back to host file.

Source

fn get_metadata(&self, node: Node) -> Result<Metadata, Error>

Get the metadata associated with the node.

Source

fn put_metadata(&mut self, node: Node, metadata: &Metadata) -> Result<(), Error>

Update the metadata associated with the node.

Source

fn get_direntry( &self, node: Node, index: DirEntryIndex, ) -> Result<DirEntry, Error>

Retrieve the DirEntry instance given the Node and DirEntryIndex.

Source

fn get_direntry_index_by_name( &self, el: &(Node, FileName), ) -> Option<DirEntryIndex>

Retrieve the DirEntryIndex instance given the Node and DirEntryIndex.

Source

fn with_direntries( &self, node: Node, initial_index: Option<DirEntryIndex>, f: &mut dyn FnMut(&DirEntryIndex, &DirEntry) -> bool, )

get entries iterator

Source

fn new_direntry_index(&self, node: Node) -> DirEntryIndex

Return the DirEntryIndex that can be used for a new entry

Source

fn put_direntry(&mut self, node: Node, index: DirEntryIndex, entry: DirEntry)

Source

fn rm_direntry(&mut self, node: Node, index: DirEntryIndex)

Source

fn read( &mut self, node: Node, read_offset: FileSize, buf: &mut [u8], ) -> Result<FileSize, Error>

Source

fn write( &mut self, node: Node, offset: FileSize, buf: &[u8], ) -> Result<FileSize, Error>

Source

fn resize_file(&mut self, node: Node, new_size: FileSize) -> Result<(), Error>

Source

fn rm_file(&mut self, node: Node) -> Result<(), Error>

Source

fn set_chunk_size(&mut self, chunk_size: ChunkSize) -> Result<(), Error>

Source

fn chunk_size(&self) -> usize

Source

fn set_chunk_type(&mut self, chunk_type: ChunkType)

Source

fn chunk_type(&self) -> ChunkType

Source

fn flush(&mut self, node: Node)

Implementors§