[−][src]Struct qstorage::QStorage
Object storage instance.
path_name
Storage root directory.chunk_size
Slice file size.block_size
Block size.context
Options file descriptor.db_context
Indexs file descriptor.drop_context
Drop indexs file descriptor.
Fields
path_name: String
chunk_size: u64
block_size: u64
engine: Engine
path: &'static str
db_path: &'static str
drop_path: &'static str
Methods
impl QStorage
[src]
pub fn new(
dirname: String,
chunk_size: u64,
block_size: u64
) -> Result<Self, Error>
[src]
dirname: String,
chunk_size: u64,
block_size: u64
) -> Result<Self, Error>
Create an object storage instance.
Initialize an instance with the given configuration.
example
let dirname = String::from("./storage"); QStorage::new(dirname, 10737418240, 1048576)?;
pub fn ready(&mut self) -> Result<&mut Self, Error>
[src]
Initialization instance.
Preparation before work.
example
let dirname = String::from("./storage"); QStorage::new(dirname, 10737418240, 1048576)?.ready()?;
pub fn closed(&mut self) -> Result<(), Error>
[src]
Turn off the storage system.
Used for shutdown processing.
- This is a required operation. You must do the final cleanup before each shutdown, save the state, you can also call this function each time you need to save the state.
- This operation will write the memory data to the file system.
- For example, listen to the exit event of the process, and then call this function.
example
let dirname = String::from("./storage"); QStorage::new(dirname, 10737418240, 1048576)?.ready()?.closed()?;
pub fn insert(&mut self, key: String, value: Vec<u8>) -> Result<(), Error>
[src]
Write data to file storage.
Write key pair data to the file system.
example
let dirname = String::from("./storage"); let mut qstorage = QStorage::new(dirname, 10737418240, 1048576)?.ready()?; qstorage.insert(String::from("hello"), "word".as_bytes().to_vec())?;
pub fn get(&mut self, key: String) -> Result<Option<Vec<u8>>, Error>
[src]
Retrieve data.
Get data based on the specified key.
example
let dirname = String::from("./storage"); let mut qstorage = QStorage::new(dirname, 10737418240, 1048576)?.ready()?; qstorage.insert(String::from("hello"), "word".as_bytes().to_vec())?; qstorage.get(String::from("hello"))?;
pub fn remove(&mut self, key: String) -> bool
[src]
Delete data.
Remove data based on the specified key.
example
let dirname = String::from("./storage"); let mut qstorage = QStorage::new(dirname, 10737418240, 1048576)?.ready()?; qstorage.insert(String::from("hello"), "word".as_bytes().to_vec())?; qstorage.remove(String::from("hello"))?;
Auto Trait Implementations
Blanket Implementations
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> From<T> for T
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,