[−][src]Struct rql::Table
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
ⓘImportant traits for RowIter<'a, T>pub fn rows(&self) -> RowIter<T>
[src]
Iterate over all rows in the Table
ⓘImportant traits for RowIterMut<'a, T>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]
F: Fn(&T) -> bool,
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]
F: Fn(&'a Self) -> I,
I: IntoIterator<Item = R>,
R: Idd<RowType = T>,
Delete rows with ids returned by an iterator
impl<T> Table<T> where
T: Serialize,
[src]
T: Serialize,
pub fn save<P>(&self, path: P, repr: Representation) -> Result<()> where
P: AsRef<Path>,
[src]
P: AsRef<Path>,
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]
T: DeserializeOwned,
pub fn load<P>(path: P, repr: Representation) -> Result<Self> where
P: AsRef<Path>,
[src]
P: AsRef<Path>,
Load a database from a file
pub fn load_from_bytes<B: AsRef<[u8]>>(
bytes: B,
repr: Representation
) -> Result<Self>
[src]
bytes: B,
repr: Representation
) -> Result<Self>
Load a database from a byte array
Trait Implementations
impl<'a, T> HasRows for &'a Table<T>
[src]
type Iter = RowIter<'a, T>
The row iterator type
fn rows(self) -> Self::Iter
[src]
ⓘImportant traits for Select<I, F>fn select<F, R>(self, f: F) -> Select<Self::Iter, F> where
F: Fn(<Self::Iter as Iterator>::Item) -> R,
[src]
F: Fn(<Self::Iter as Iterator>::Item) -> R,
Create a selection
ⓘImportant traits for Relate<A, B, F>fn relate<R, F>(self, other: R, f: F) -> Relate<Self::Iter, R::Iter, F> where
R: HasRows,
R::Iter: Clone,
<Self::Iter as Iterator>::Item: Clone,
F: Fn(&<Self::Iter as Iterator>::Item, &<R::Iter as Iterator>::Item) -> bool,
[src]
R: HasRows,
R::Iter: Clone,
<Self::Iter as Iterator>::Item: Clone,
F: Fn(&<Self::Iter as Iterator>::Item, &<R::Iter as Iterator>::Item) -> bool,
Relate this HasRows
to another
ⓘImportant traits for Where<I, F>fn wher<F>(self, f: F) -> Where<Self::Iter, F> where
F: Fn(&<Self::Iter as Iterator>::Item) -> bool,
[src]
F: Fn(&<Self::Iter as Iterator>::Item) -> bool,
Restricts the rows with a WHERE
clause
fn find<F>(self, f: F) -> Option<<Self::Iter as Iterator>::Item> where
F: Fn(&<Self::Iter as Iterator>::Item) -> bool,
[src]
F: Fn(&<Self::Iter as Iterator>::Item) -> bool,
Tries to find a row that satisfies the clause
impl<'a, T> HasRows for &'a mut Table<T>
[src]
type Iter = RowIter<'a, T>
The row iterator type
fn rows(self) -> Self::Iter
[src]
ⓘImportant traits for Select<I, F>fn select<F, R>(self, f: F) -> Select<Self::Iter, F> where
F: Fn(<Self::Iter as Iterator>::Item) -> R,
[src]
F: Fn(<Self::Iter as Iterator>::Item) -> R,
Create a selection
ⓘImportant traits for Relate<A, B, F>fn relate<R, F>(self, other: R, f: F) -> Relate<Self::Iter, R::Iter, F> where
R: HasRows,
R::Iter: Clone,
<Self::Iter as Iterator>::Item: Clone,
F: Fn(&<Self::Iter as Iterator>::Item, &<R::Iter as Iterator>::Item) -> bool,
[src]
R: HasRows,
R::Iter: Clone,
<Self::Iter as Iterator>::Item: Clone,
F: Fn(&<Self::Iter as Iterator>::Item, &<R::Iter as Iterator>::Item) -> bool,
Relate this HasRows
to another
ⓘImportant traits for Where<I, F>fn wher<F>(self, f: F) -> Where<Self::Iter, F> where
F: Fn(&<Self::Iter as Iterator>::Item) -> bool,
[src]
F: Fn(&<Self::Iter as Iterator>::Item) -> bool,
Restricts the rows with a WHERE
clause
fn find<F>(self, f: F) -> Option<<Self::Iter as Iterator>::Item> where
F: Fn(&<Self::Iter as Iterator>::Item) -> bool,
[src]
F: Fn(&<Self::Iter as Iterator>::Item) -> bool,
Tries to find a row that satisfies the clause
impl<'a, T> HasRowsMut for &'a mut Table<T>
[src]
type Iter = RowIterMut<'a, T>
The row iterator type
fn rows_mut(self) -> Self::Iter
[src]
fn update(self) -> Self::Iter
[src]
Update the rows
impl<T: Clone> Clone for Table<T>
[src]
fn clone(&self) -> Table<T>
[src]
fn clone_from(&mut self, source: &Self)
1.0.0[src]
Performs copy-assignment from source
. Read more
impl<T> Default for Table<T>
[src]
impl<T> Debug for Table<T> where
T: Debug,
[src]
T: Debug,
impl<T> Serialize for Table<T> where
T: Serialize,
[src]
T: Serialize,
fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error> where
__S: Serializer,
[src]
__S: Serializer,
impl<'de, T> Deserialize<'de> for Table<T> where
T: Deserialize<'de>,
[src]
T: Deserialize<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error> where
__D: Deserializer<'de>,
[src]
__D: Deserializer<'de>,
Auto Trait Implementations
impl<T> Unpin for Table<T> where
T: Unpin,
T: Unpin,
impl<T> Sync for Table<T> where
T: Sync,
T: Sync,
impl<T> Send for Table<T> where
T: Send,
T: Send,
impl<T> UnwindSafe for Table<T> where
T: UnwindSafe,
T: UnwindSafe,
impl<T> RefUnwindSafe for Table<T> where
T: RefUnwindSafe,
T: RefUnwindSafe,
Blanket Implementations
impl<T> From<T> for T
[src]
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
fn to_owned(&self) -> T
[src]
fn clone_into(&self, target: &mut T)
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> DeserializeOwned for T where
T: Deserialize<'de>,
[src]
T: Deserialize<'de>,