pub struct LsmFile<T, K>{ /* private fields */ }
Expand description
Implementations§
Source§impl<T, K> LsmFile<T, K>
impl<T, K> LsmFile<T, K>
Sourcepub fn new(
file: T,
compression: Option<i32>,
key: Arc<K>,
max_cache_entries: Option<usize>,
) -> Result<Self, BackendError>
pub fn new( file: T, compression: Option<i32>, key: Arc<K>, max_cache_entries: Option<usize>, ) -> Result<Self, BackendError>
Creates a new LsmFile
from the provided, already existing, File
like object.
Accepts values for the compression level for the file, the key to be used for encryption/decryption, as well as the maximum number of cache entries before a mandatory flush occurs, which defaults to 100.
§Errors
Error::EntryIO
if an error occurs while reading the entries- Will bubble up any segment errors`
Sourcepub fn get<C, V>(&mut self, key: &C) -> Result<Option<V>, BackendError>where
C: Serialize,
V: DeserializeOwned,
pub fn get<C, V>(&mut self, key: &C) -> Result<Option<V>, BackendError>where
C: Serialize,
V: DeserializeOwned,
Retries a value from the store given a key, if the value exists in the store.
The most recently inserted version of the value will be returned
§Errors
Will return an error if any IO error occurs, or if the value fails to deserialize.
Sourcepub fn insert<C, V>(&mut self, key: &C, value: &V) -> Result<(), BackendError>
pub fn insert<C, V>(&mut self, key: &C, value: &V) -> Result<(), BackendError>
Inserts an object into the store
This method will write to the cache, however, if this insertion makes the cache size greater than or equal to the maximum number of entries, the current cache will be flushed.
§Errors
- Will return an error if either the key or value fail to serialize
- Will bubble up any IO errors that occur, if a flush occurs
Sourcepub fn flush(&mut self) -> Result<(), BackendError>
pub fn flush(&mut self) -> Result<(), BackendError>
Sourcepub fn to_hashmap<C, V>(&mut self) -> Result<HashMap<C, V>, BackendError>
pub fn to_hashmap<C, V>(&mut self) -> Result<HashMap<C, V>, BackendError>
Sourcepub fn into_inner(self) -> T
pub fn into_inner(self) -> T
Consumes self and returns the inner File
like object
Source§impl<K> LsmFile<File, K>where
K: Key,
impl<K> LsmFile<File, K>where
K: Key,
Sourcepub fn open(
path: impl AsRef<Path> + Debug,
compression: Option<i32>,
key: Arc<K>,
max_cache_entries: Option<usize>,
) -> Result<Self, BackendError>
pub fn open( path: impl AsRef<Path> + Debug, compression: Option<i32>, key: Arc<K>, max_cache_entries: Option<usize>, ) -> Result<Self, BackendError>
Opens an existing LsmFile
from the provided path.
Will open the file in read/write mode. Will fail if the file does not exists.
§Errors
- If the file does not exist
- If any other IO occurs
- If any of the decryption or deserialization of control structures fails
Sourcepub fn create(
path: impl AsRef<Path> + Debug,
compression: Option<i32>,
key: Arc<K>,
max_cache_entries: Option<usize>,
) -> Result<Self, BackendError>
pub fn create( path: impl AsRef<Path> + Debug, compression: Option<i32>, key: Arc<K>, max_cache_entries: Option<usize>, ) -> Result<Self, BackendError>
Opens an existing LsmFile
from the provided path.
Will create the file in read/write mode, failing if the file exists
§Errors
- If the file already exists
- If any other IO occurs