[][src]Struct rql::Table

pub struct Table<T> { /* fields omitted */ }

A table abstraction akin to a table in a real schema

Methods

impl<T> Table<T>[src]

pub fn new() -> Self[src]

Create a new Table

pub fn len(&self) -> usize[src]

Get the number of rows in the Table

pub fn is_empty(&self) -> bool[src]

Check if the Table` is empty

pub fn insert(&mut self, row: T) -> Id<T>[src]

Insert a row into the Table

pub fn get(&self, id: Id<T>) -> Option<&T>[src]

Try to get a reference to the row with the given Id

pub fn get_mut(&mut self, id: Id<T>) -> Option<&mut T>[src]

Try to get a mutable reference to the row with the given Id

pub fn remove(&mut self, id: Id<T>) -> Option<T>[src]

Remove the row with the given Id

pub fn rows(&self) -> RowIter<T>[src]

Iterate over all rows in the Table

pub fn rows_mut(&mut self) -> RowIterMut<T>[src]

Iterate mutably over all rows in the Table

pub fn delete_one(&mut self, id: Id<T>) -> Option<T>[src]

Delete a single row based on its Id and return the value

pub fn delete_where<F>(&mut self, f: F) -> usize where
    F: Fn(&T) -> bool
[src]

Delete rows that satisfy the clause

Returns how many rows where deleted

pub fn delete_iter<'a, F, I, R>(&'a mut self, f: F) where
    F: Fn(&'a Self) -> I,
    I: IntoIterator<Item = R>,
    R: Idd<RowType = T>, 
[src]

Delete rows with ids returned by an iterator

impl<T> Table<T> where
    T: Serialize
[src]

pub fn save<P>(&self, path: P, repr: Representation) -> Result<()> where
    P: AsRef<Path>, 
[src]

Save the database to a file

pub fn save_to_bytes(&self, repr: Representation) -> Result<Vec<u8>>[src]

Save the database to a byte vector

impl<T> Table<T> where
    T: DeserializeOwned
[src]

pub fn load<P>(path: P, repr: Representation) -> Result<Self> where
    P: AsRef<Path>, 
[src]

Load a database from a file

pub fn load_from_bytes<B: AsRef<[u8]>>(
    bytes: B,
    repr: Representation
) -> Result<Self>
[src]

Load a database from a byte array

Trait Implementations

impl<T: Clone> Clone for Table<T>[src]

impl<T> Debug for Table<T> where
    T: Debug
[src]

impl<T> Default for Table<T>[src]

impl<'de, T> Deserialize<'de> for Table<T> where
    T: Deserialize<'de>, 
[src]

impl<'a, T> HasRows for &'a Table<T>[src]

type Iter = RowIter<'a, T>

The row iterator type

impl<'a, T> HasRows for &'a mut Table<T>[src]

type Iter = RowIter<'a, T>

The row iterator type

impl<'a, T> HasRowsMut for &'a mut Table<T>[src]

type Iter = RowIterMut<'a, T>

The row iterator type

impl<T> Serialize for Table<T> where
    T: Serialize
[src]

Auto Trait Implementations

impl<T> RefUnwindSafe for Table<T> where
    T: RefUnwindSafe

impl<T> Send for Table<T> where
    T: Send

impl<T> Sync for Table<T> where
    T: Sync

impl<T> Unpin for Table<T> where
    T: Unpin

impl<T> UnwindSafe for Table<T> where
    T: UnwindSafe

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> DeserializeOwned for T where
    T: for<'de> Deserialize<'de>, 
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.

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