Struct Table

Source
pub struct Table<'b, T>
where T: TableLayout,
{ /* private fields */ }
Expand description

A table of values from an oppened database.

Implementations§

Source§

impl<'b, T> Table<'b, T>
where T: TableLayout,

Source

pub fn get<'t, K>(&'t self, key: &K) -> Option<T>
where K: TableKey<'t, T>,

Gets an item from the table if it exists.

Source

pub fn push(&self, element: T) -> KeyRef<'_, '_, T>

pushes a new value at the end of the table.

Source

pub fn set<'t, K>(&'t self, key: &K, value: T)
where K: TableKey<'t, T>,

Sets an entry of the table to a certain value.

Source

pub fn delete<'t, K>(&'t self, key: &K)
where K: TableKey<'t, T>,

Source

pub fn update<'t, K, F>(&'t self, key: &K, op: F)
where K: TableKey<'t, T>, F: FnOnce(&mut Option<T>),

updates an entry. If it did not existed but Some(_) is set by the closure, then it is stored. If it existed but None is set by the closure, then it is deleted.

Source

pub fn keys<'t>(&'t self) -> impl Iterator<Item = KeyRef<'t, 'b, T>>

Source

pub fn iter<'t>(&'t self) -> impl Iterator<Item = (KeyRef<'t, 'b, T>, T)>

Trait Implementations§

Source§

impl<'b, T> Debug for Table<'b, T>
where T: TableLayout + Debug,

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<'b, T> Freeze for Table<'b, T>

§

impl<'b, T> !RefUnwindSafe for Table<'b, T>

§

impl<'b, T> Send for Table<'b, T>

§

impl<'b, T> Sync for Table<'b, T>

§

impl<'b, T> Unpin for Table<'b, T>

§

impl<'b, T> !UnwindSafe for Table<'b, T>

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> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
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.