TableInner

Struct TableInner 

Source
pub struct TableInner<T>
where T: TableType + 'static,
{ /* private fields */ }

Implementations§

Source§

impl<T> TableInner<T>
where T: TableType,

Source

pub fn insert(&self, value: T) -> DbResult<u64>

Insert a new record into the table.

§Arguments
  • value - The value to insert.
§Returns

The ID of the new record.

Source

pub fn select(&self, id: u64) -> DbResult<Option<Record<T>>>

Select a record by its ID.

§Arguments
  • id - The ID of the record to select.
§Returns

An Option containing the selected record if it exists, or None otherwise.

Source

pub fn delete(&self, id: u64) -> DbResult<Option<Record<T>>>

Delete a record by its ID.

§Arguments
  • id - The ID of the record to delete.
§Returns

An Option containing the deleted record if it exists, or None otherwise.

Source

pub fn update( &self, ids: &[u64], updater: fn(T) -> T, ) -> DbResult<Vec<Record<T>>>

Update one or more records by their IDs.

§Arguments
  • ids - The IDs of the records to update.
  • updater - Closure to generate the new data based on the old data.
§Returns

All updated records.

Source

pub fn create_index<I: IndexType>( &self, name: &str, key_func: impl Fn(&T) -> I + Send + Sync + 'static, ) -> DbResult<Index<T, I>>

Create an index on the table.

§Arguments
  • name - The name of the index.
  • key_func - A function which computes the index key for each record.
§Returns

An Index instance for the created index.

Source

pub fn constraint(&self, constraint: Constraint<T>) -> DbResult<()>

Add a constraint to the table.

§Arguments
  • constraint - The constraint to add.

Auto Trait Implementations§

§

impl<T> !Freeze for TableInner<T>

§

impl<T> !RefUnwindSafe for TableInner<T>

§

impl<T> !Send for TableInner<T>

§

impl<T> !Sync for TableInner<T>

§

impl<T> Unpin for TableInner<T>

§

impl<T> !UnwindSafe for TableInner<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.