Skip to main content

KomerBase

Struct KomerBase 

Source
pub struct KomerBase<T>
where T: Serialize + for<'de> Deserialize<'de> + Debug,
{ pub sdb: Database<Bytes, Bytes>, pub kind: SerialKind, pub sep: String, /* private fields */ }
Expand description

KomerBase is a base struct for Komer (Keyspace Object Mapper) implementations that each use a struct (with Serialize/Deserialize) as the object mapped via serialization to an LMDB database.

Fields§

§sdb: Database<Bytes, Bytes>

LMDB database instance for this Komer

§kind: SerialKind

Serialization format

§sep: String

Separator for combining keys

Implementations§

Source§

impl<T> KomerBase<T>
where T: Serialize + for<'de> Deserialize<'de> + Debug,

Source

pub fn new( db: Arc<LMDBer>, subkey: &str, kind: SerialKind, dupsort: bool, sep: Option<&str>, ) -> Result<Self, KomerError>

Create a new KomerBase instance

Source

pub fn to_key<K: AsRef<[u8]>>(&self, keys: &[K], topive: bool) -> Vec<u8> ⓘ

Source

pub fn to_keys(&self, key: &[u8]) -> Vec<String>

Converts key bytes to keys tuple of strings

Source

pub fn serialize(&self, val: &T) -> Result<Vec<u8>, KomerError>

Serialize a value using the configured serializer

Source

pub fn deserialize(&self, val: &[u8]) -> Result<T, KomerError>

Deserialize a value using the configured deserializer

Source

pub fn get_item_iter<K>( &self, keys: &[K], ) -> Result<Vec<(Vec<String>, T)>, KomerError>
where K: AsRef<[u8]>,

Get an iterator over items with keys starting with the provided prefix

Source

pub fn get_full_item_iter<K>( &self, keys: &[K], ) -> Result<Vec<(Vec<String>, T)>, KomerError>
where K: AsRef<[u8]>,

Get full item iterator (same as get_item_iter in this implementation)

Source

pub fn put<K>(&self, keys: &[K], val: &T) -> Result<bool, KomerError>
where K: AsRef<[u8]>,

Put a value into the database with the given keys

Source

pub fn get<K>(&self, keys: &[K]) -> Result<Option<T>, KomerError>
where K: AsRef<[u8]>,

Get a value from the database with the given keys

Source

pub fn rem<K>(&self, keys: &[K]) -> Result<bool, KomerError>
where K: AsRef<[u8]>,

Remove a value from the database with the given keys

Source

pub fn cnt_all(&self) -> Result<usize, KomerError>

Count all items in the database

Auto Trait Implementations§

§

impl<T> Freeze for KomerBase<T>

§

impl<T> RefUnwindSafe for KomerBase<T>
where T: RefUnwindSafe,

§

impl<T> Send for KomerBase<T>
where T: Send,

§

impl<T> Sync for KomerBase<T>
where T: Sync,

§

impl<T> Unpin for KomerBase<T>
where T: Unpin,

§

impl<T> UnsafeUnpin for KomerBase<T>

§

impl<T> UnwindSafe for KomerBase<T>
where T: UnwindSafe,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V

§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more