[][src]Struct dodo::repository::RepositoryCursor

pub struct RepositoryCursor<'a, T, S, I, R> { /* fields omitted */ }

Repository cursor, yeilding all entities inside the repository.

Example

let entities = repository.find_all()?
                         .filter(|person| person.age > 20)
                         .skip(1)
                         .take(3)?;

Methods

impl<'a, T, S, R> RepositoryCursor<'a, T, S, S::Iterator, R> where
    T: Entity,
    S: Storage,
    R: Serializer
[src]

pub fn shuffled(self) -> RepositoryCursor<'a, T, S, IntoIter<Result<Uuid>>, R>[src]

Shuffles the order the entities are yielded.

Use this if you need to shuffle the entire repository contents. When done this early, this shuffles ids, not entities, so it is pretty lightweight. Nevertheless, this still has some serious performance implications, as this collects every id in the storage. With a small repository, this shouldn't be a problem, but with a large one, this will allocate a substantial amount of memory.

Examples

let mut person1 = Person::new();
let mut person2 = Person::new();
repository.insert(&mut person1)?;
repository.insert(&mut person2)?;

let persons : Vec<Person> = repository.find_all()?
                                      .shuffled()
                                      .collect()?;

assert!(persons.contains(&person1), "Person1 should be in the results.");
assert!(persons.contains(&person2), "Person2 should be in the results.");

Trait Implementations

impl<'a, T, S, I, R> Cursor for RepositoryCursor<'a, T, S, I, R> where
    T: Entity,
    S: Storage,
    I: Iterator<Item = Result<Uuid>>,
    R: Serializer
[src]

type Item = T

Entity.

impl<'a, T: Debug, S: Debug, I: Debug, R: Debug> Debug for RepositoryCursor<'a, T, S, I, R>[src]

Auto Trait Implementations

impl<'a, T, S, I, R> RefUnwindSafe for RepositoryCursor<'a, T, S, I, R> where
    I: RefUnwindSafe,
    R: RefUnwindSafe,
    S: RefUnwindSafe,
    T: RefUnwindSafe

impl<'a, T, S, I, R> Send for RepositoryCursor<'a, T, S, I, R> where
    I: Send,
    R: Send,
    S: Sync,
    T: Send

impl<'a, T, S, I, R> Sync for RepositoryCursor<'a, T, S, I, R> where
    I: Sync,
    R: Sync,
    S: Sync,
    T: Sync

impl<'a, T, S, I, R> Unpin for RepositoryCursor<'a, T, S, I, R> where
    I: Unpin,
    R: Unpin,
    T: Unpin

impl<'a, T, S, I, R> UnwindSafe for RepositoryCursor<'a, T, S, I, R> where
    I: UnwindSafe,
    R: UnwindSafe,
    S: RefUnwindSafe,
    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> 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>,