Skip to main content

IoSetSuber

Struct IoSetSuber 

Source
pub struct IoSetSuber<C: ValueCodec = Utf8Codec> {
    pub base: SuberBase<C>,
}
Expand description

Represents an Insertion Ordered Set Suber.

Fields§

§base: SuberBase<C>

Implementations§

Source§

impl<C: ValueCodec> IoSetSuber<C>

Source

pub fn new( db: Arc<LMDBer>, subkey: &str, sep: Option<u8>, verify: bool, ) -> Result<Self, SuberError>

Creates a new IoSetSuber.

Source

pub fn put<K: AsRef<[u8]>, V: ?Sized + Clone + Into<Vec<u8>>>( &self, keys: &[K], vals: &[&V], ) -> Result<bool, SuberError>

Puts multiple values into the set associated with the given keys.

Adds only values that are not already present in the set for the effective key. Does not overwrite existing identical values. Values are appended in insertion order.

§Arguments
  • keys: An array slice of key parts.
  • vals: An array slice of values to put.
§Returns

Ok(true) if the operation was successful (note: underlying LMDB operation might always return true here). Ok(false) if the operation failed at the LMDB level. Returns Err(SuberError) on key/value processing or database errors.

Source

pub fn add<K: AsRef<[u8]>, V: ?Sized + Clone + Into<Vec<u8>>>( &self, keys: &[K], val: &V, ) -> Result<bool, SuberError>

Adds a single value idempotently to the set associated with the given keys.

If the value already exists in the set for the effective key, it is not added again.

§Arguments
  • keys: An array slice of key parts.
  • val: The value to add.
§Returns

Ok(true) if the value was added (i.e., it was not already present). Ok(false) if the value was already present. Returns Err(SuberError) on key/value processing or database errors.

Source

pub fn pin<K: AsRef<[u8]>, V: ?Sized + Clone + Into<Vec<u8>>>( &self, keys: &[K], vals: &[&V], ) -> Result<bool, SuberError>

Pins (sets/replaces) the values associated with the given keys.

Removes all pre-existing values for the effective key and replaces them with the provided vals.

§Arguments
  • keys: An array slice of key parts.
  • vals: An array slice of the new values to set.
§Returns

Ok(true) if the operation was successful. Ok(false) if the operation failed at the LMDB level. Returns Err(SuberError) on key/value processing or database errors. Pins (sets/replaces) the values associated with the given keys.

Removes all pre-existing values for the effective key and replaces them with the provided vals. Each value is serialized using the configured ValueCodec before storage.

§Arguments
  • keys: An array slice of key parts.
  • vals: An array slice of the new values to set.
§Returns

Ok(true) if the operation was successful. Ok(false) if the operation failed at the LMDB level. Returns Err(SuberError) on key/value processing or database errors.

Source

pub fn get<K: AsRef<[u8]>, R: TryFrom<Vec<u8>>>( &self, keys: &[K], ) -> Result<Vec<R>, SuberError>
where <R as TryFrom<Vec<u8>>>::Error: Debug,

Gets all values in the set associated with the given keys, in insertion order.

§Arguments
  • keys: An array slice of key parts.
§Returns

Ok(Vec<R>) containing the deserialized values. Returns an empty Vec if the key doesn’t exist. Err(SuberError) on key processing or database/deserialization errors.

Source

pub fn get_iter<K: AsRef<[u8]>, R: TryFrom<Vec<u8>> + 'static>( &self, keys: &[K], ) -> Result<impl Iterator<Item = Result<R, SuberError>>, SuberError>
where <R as TryFrom<Vec<u8>>>::Error: Debug, SuberError: From<<R as TryFrom<Vec<u8>>>::Error>,

Gets an iterator over the values in the set associated with the given keys.

Values are yielded in insertion order. Note: This implementation collects into a Vec first due to the underlying callback mechanism. A true iterator might require a more complex setup or modification to LMDBer.

§Arguments
  • keys: An array slice of key parts.
§Returns

Ok(impl Iterator<Item = Result<R, SuberError>>) yielding deserialized values. Err(SuberError) on key processing or initial database errors.

Source

pub fn get_last<K: AsRef<[u8]>, R: TryFrom<Vec<u8>>>( &self, keys: &[K], ) -> Result<Option<R>, SuberError>
where <R as TryFrom<Vec<u8>>>::Error: Debug,

Gets the last value inserted into the set for the given keys.

§Arguments
  • keys: An array slice of key parts.
§Returns

Ok(Some(R)) containing the deserialized last value if found. Ok(None) if the key does not exist or the set is empty. Err(SuberError) on key processing or database/deserialization errors.

Source

pub fn rem<K: AsRef<[u8]>, V: ?Sized + Clone + Into<Vec<u8>>>( &self, keys: &[K], val: Option<&V>, ) -> Result<bool, SuberError>

Removes entries associated with the given keys.

If val is Some, removes the specific value from the set if it exists. If val is None, removes all values associated with the effective key.

§Arguments
  • keys: An array slice of key parts.
  • val: An Option containing the specific value to remove, or None to remove all.
§Returns

Ok(true) if the specified value or the entire key entry was found and removed. Ok(false) if the specified value or key was not found. Err(SuberError) on key/value processing or database errors.

Source

pub fn cnt<K: AsRef<[u8]>>(&self, keys: &[K]) -> Result<usize, SuberError>

Counts the number of values in the set associated with the given keys.

§Arguments
  • keys: An array slice of key parts.
§Returns

Ok(usize) containing the count of values (0 if the key doesn’t exist). Err(SuberError) on key processing or database errors.

Source

pub fn get_item_iter<K: AsRef<[u8]>, R: TryFrom<Vec<u8>>>( &self, keys: &[K], topive: bool, ) -> Result<Vec<(Vec<Vec<u8>>, R)>, SuberError>

Returns an iterator over (keys, value) items whose effective key starts with the prefix derived from keys.

Note: Similar to get_iter, this collects results first due to the callback mechanism. The keys returned in the tuple are split based on the separator.

§Arguments
  • keys: An array slice of key parts forming the prefix.
  • topive: If true, treat keys as a partial prefix (appends separator).
§Returns

Ok(Vec<(Vec<Vec<u8>>, R)>) containing tuples of (split key parts, deserialized value). Err(SuberError) on key processing or database/deserialization errors.

Source

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

Returns an iterator over all the items including all raw items for all keys in top branch defined by keys where keys may be truncation of full branch. Returns full raw values with ordinal suffixes.

§Arguments
  • keys - Slice of key parts, potentially a partial key
  • topive - If true, treat as partial key tuple ending with separator
§Returns
  • Result<Vec<(Vec<Vec<u8>>, Vec<u8>)>, SuberError> - Vector of key-value pairs with raw values
Source

pub fn trim<K: AsRef<[u8]>>( &self, keys: &[K], topive: bool, ) -> Result<bool, SuberError>

Removes all entries at keys that are in top branch with key prefix matching keys where keys may be truncation of full branch.

Source

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

Converts a collection of keys to a single key byte vector

Source

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

Converts a key to a vector of key parts

Source

pub fn _ser<T: ?Sized + Clone + Into<Vec<u8>>>( &self, val: &T, ) -> Result<Vec<u8>, SuberError>

Serialize a value to bytes

Source

pub fn _des<T: TryFrom<Vec<u8>>>(&self, val: &[u8]) -> Result<T, SuberError>

Deserialize bytes to a value

Source

pub fn cntAll(&self) -> Result<usize, SuberError>

Count all items in the database

Auto Trait Implementations§

§

impl<C> Freeze for IoSetSuber<C>

§

impl<C> RefUnwindSafe for IoSetSuber<C>
where C: RefUnwindSafe,

§

impl<C> Send for IoSetSuber<C>
where C: Send,

§

impl<C> Sync for IoSetSuber<C>
where C: Sync,

§

impl<C> Unpin for IoSetSuber<C>
where C: Unpin,

§

impl<C> UnsafeUnpin for IoSetSuber<C>

§

impl<C> UnwindSafe for IoSetSuber<C>
where C: 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