pub struct List<'a, Cn, Cl, PrimaryKey>where
Cl: Collection,
PrimaryKey: PartialEq + ?Sized,
Cl::PrimaryKey: Borrow<PrimaryKey> + PartialEq<PrimaryKey>,{ /* private fields */ }Expand description
Retrieves a list of documents from a collection. This structure also offers functions to customize the options for the operation.
Implementations§
Source§impl<'a, Cn, Cl, PrimaryKey> List<'a, Cn, Cl, PrimaryKey>where
Cl: Collection,
Cn: Connection,
PrimaryKey: KeyEncoding<Cl::PrimaryKey> + PartialEq + 'a + ?Sized,
Cl::PrimaryKey: Borrow<PrimaryKey> + PartialEq<PrimaryKey>,
impl<'a, Cn, Cl, PrimaryKey> List<'a, Cn, Cl, PrimaryKey>where
Cl: Collection,
Cn: Connection,
PrimaryKey: KeyEncoding<Cl::PrimaryKey> + PartialEq + 'a + ?Sized,
Cl::PrimaryKey: Borrow<PrimaryKey> + PartialEq<PrimaryKey>,
Sourcepub const fn descending(self) -> Self
pub const fn descending(self) -> Self
Lists documents by id in descending order.
Sourcepub const fn limit(self, maximum_results: u32) -> Self
pub const fn limit(self, maximum_results: u32) -> Self
Sets the maximum number of results to return.
Sourcepub fn count(self) -> Result<u64, Error>
pub fn count(self) -> Result<u64, Error>
Returns the number of documents contained within the range.
Order and limit are ignored if they were set.
println!(
"Number of documents with id 42 or larger: {}",
db.collection::<MyCollection>().list(&42..).count()?
);
println!(
"Number of documents in MyCollection: {}",
db.collection::<MyCollection>().all().count()?
);Sourcepub fn headers(self) -> Result<Vec<Header>, Error>
pub fn headers(self) -> Result<Vec<Header>, Error>
Returns the list of headers for documents contained within the range.
println!(
"Headers with id 42 or larger: {:?}",
db.collection::<MyCollection>().list(&42..).headers()?
);
println!(
"Headers in MyCollection: {:?}",
db.collection::<MyCollection>().all().headers()?
);Sourcepub fn query(self) -> Result<Vec<OwnedDocument>, Error>
pub fn query(self) -> Result<Vec<OwnedDocument>, Error>
Retrieves the matching documents.
for doc in db.collection::<MyCollection>().all().query()? {
println!("Retrieved #{} with bytes {:?}", doc.header.id, doc.contents);
let deserialized = MyCollection::document_contents(&doc)?;
println!("Deserialized contents: {:?}", deserialized);
}Auto Trait Implementations§
impl<'a, Cn, Cl, PrimaryKey> Freeze for List<'a, Cn, Cl, PrimaryKey>
impl<'a, Cn, Cl, PrimaryKey> RefUnwindSafe for List<'a, Cn, Cl, PrimaryKey>where
Cn: RefUnwindSafe,
Cl: RefUnwindSafe,
<Cl as Collection>::PrimaryKey: RefUnwindSafe,
PrimaryKey: RefUnwindSafe + ?Sized,
impl<'a, Cn, Cl, PrimaryKey> Send for List<'a, Cn, Cl, PrimaryKey>
impl<'a, Cn, Cl, PrimaryKey> Sync for List<'a, Cn, Cl, PrimaryKey>
impl<'a, Cn, Cl, PrimaryKey> Unpin for List<'a, Cn, Cl, PrimaryKey>
impl<'a, Cn, Cl, PrimaryKey> UnwindSafe for List<'a, Cn, Cl, PrimaryKey>where
Cn: RefUnwindSafe,
Cl: UnwindSafe + RefUnwindSafe,
<Cl as Collection>::PrimaryKey: UnwindSafe,
PrimaryKey: RefUnwindSafe + ?Sized,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more