[][src]Struct structsy::StructsyQuery

pub struct StructsyQuery<T: Persistent + 'static> { /* fields omitted */ }

Query for a persistent struct

Example

use structsy::{ Structsy, StructsyTx, StructsyError};
use structsy_derive::{queries, Persistent};
#[derive(Persistent)]
struct Basic {
    name: String,
}
impl Basic {
    fn new(name: &str) -> Basic {
        Basic { name: name.to_string() }
    }
}

#[queries(Basic)]
trait BasicQuery {
     fn by_name(self, name: String) -> Self;
}


fn basic_query() -> Result<(), StructsyError> {
    let structsy = Structsy::open("file.structsy")?;
    structsy.define::<Basic>()?;
    let mut tx = structsy.begin()?;
    tx.insert(&Basic::new("aaa"))?;
    tx.commit()?;
    let count = structsy.query::<Basic>().by_name("aaa".to_string()).into_iter().count();
    assert_eq!(count, 1);
    Ok(())
}

Implementations

impl<T: Persistent + 'static> StructsyQuery<T>[src]

pub fn projection<P: Projection<T>>(self) -> ProjectionQuery<P, T>[src]

Trait Implementations

impl<T: Persistent> IntoIterator for StructsyQuery<T>[src]

type Item = (Ref<T>, T)

The type of the elements being iterated over.

type IntoIter = StructsyIter<'static, (Ref<T>, T)>

Which kind of iterator are we turning this into?

impl<T: Persistent + 'static> Query<T> for StructsyQuery<T>[src]

impl<T: 'static, V> QueryAction<StructsyQuery<V>> for (Field<T, Ref<V>>, &mut EmbeddedFilterBuilder<T>) where
    V: Persistent + 'static, 
[src]

impl<T, V> QueryAction<StructsyQuery<V>> for (Field<T, Option<Ref<V>>>, &mut FilterBuilder<T>) where
    T: Persistent + 'static,
    V: Persistent + 'static, 
[src]

impl<T, V> QueryAction<StructsyQuery<V>> for (Field<T, Ref<V>>, &mut FilterBuilder<T>) where
    T: Persistent + 'static,
    V: Persistent + 'static, 
[src]

impl<T, V> QueryAction<StructsyQuery<V>> for (Field<T, Vec<Ref<V>>>, &mut FilterBuilder<T>) where
    T: Persistent + 'static,
    V: Persistent + 'static, 
[src]

Auto Trait Implementations

impl<T> !RefUnwindSafe for StructsyQuery<T>[src]

impl<T> !Send for StructsyQuery<T>[src]

impl<T> !Sync for StructsyQuery<T>[src]

impl<T> Unpin for StructsyQuery<T>[src]

impl<T> !UnwindSafe for StructsyQuery<T>[src]

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> From<T> for T[src]

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

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