Struct BTree

Source
pub struct BTree { /* private fields */ }
Expand description

BTree is where the informatio Sender is contained. Its inner implementation has a tuple containing the action to be taken as well as a oneshot channel to receive data. To start the BTree thread just execute BTree::start(buffer_size: usize). If you buffer_size is too short it may cause synchronization problems, so it should be well ajusted to your application needs.

Implementations§

Source§

impl BTree

Source

pub fn start(buffer_size: usize) -> Self

BTree::start(buffer_size: usize) is the entrypoint to start using BTree methods. It creates a thread containing the BTreeMap and keeps listening to entries.

Source

pub async fn insert<V: Into<Types>>( &self, k: String, v: V, ) -> Result<Option<Types>, String>

Method insert is equivalent to std::collection::BTreeMap insert, it returns None if the key does not exist and it returns Some(Types::_) with the previous value, if the key already exists.

Source

pub async fn contains(&self, k: String) -> Result<bool, String>

Method contains is equivalent to std::collection::BTreeMap contains_key, It checks if a key already exists in the BTree. If the key exists the return is Ok(true), if it doesn’t exist it returns Ok(false)

Source

pub async fn get(&self, k: String) -> Result<Option<Types>, String>

Method get is equivalent to std::collection::BTreeMap get, It returns the value contained at the key passed as argument. If no key is found the return is Ok(None), else it returns Ok(Some(Types::_)).

Source

pub async fn len(&self) -> Result<usize, String>

Method len is equivalent to std::collection::BTreeMap len, It returns the length of the btree as a usize.

Source

pub async fn keys(&self) -> Result<Vec<String>, String>

Method keys is equivalent to std::collection::BTreeMap keys, It returns a vector containing all the keys sorted. For BTree the keys are always Strings.

Source

pub async fn values(&self) -> Result<Vec<Types>, String>

Method values is equivalent to std::collection::BTreeMap values, It returns a vector containing all the values sorted by their respective keys order.

Source

pub async fn remove(&self, k: String) -> Result<Option<Types>, String>

Method remove is equivalent to std::collection::BTreeMap remove, It returns the value removed from the BTree for the key passed as argument. If no key is found the return is Ok(None), else it returns Ok(Some(Types::_)).

Source

pub async fn remove_entry(&self, k: String) -> Result<Option<Types>, String>

Method remove_entry is equivalent to std::collection::BTreeMap remove_entry, It returns the key and value removed from the BTree for the key passed as argument as a Option<Types::KeyValue(_,_)>. If no key is found the return is Ok(None),

Auto Trait Implementations§

§

impl Freeze for BTree

§

impl !RefUnwindSafe for BTree

§

impl Send for BTree

§

impl Sync for BTree

§

impl Unpin for BTree

§

impl !UnwindSafe for BTree

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.

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, 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.