Struct bonsaidb_core::schema::Entry
source · pub struct Entry<'a, 'name, Connection, Col, EI, EU>{ /* private fields */ }
Expand description
A future that resolves to an entry in a NamedCollection
.
Implementations§
source§impl<'a, 'name, Connection, Col, EI, EU> Entry<'a, 'name, Connection, Col, EI, EU>where
Col: NamedCollection + SerializedCollection + 'static + Unpin,
Connection: Connection,
EI: EntryInsert<Col> + 'a + Unpin,
EU: EntryUpdate<Col> + 'a + Unpin,
'name: 'a,
impl<'a, 'name, Connection, Col, EI, EU> Entry<'a, 'name, Connection, Col, EI, EU>where
Col: NamedCollection + SerializedCollection + 'static + Unpin,
Connection: Connection,
EI: EntryInsert<Col> + 'a + Unpin,
EU: EntryUpdate<Col> + 'a + Unpin,
'name: 'a,
sourcepub fn execute(self) -> Result<Option<CollectionDocument<Col>>, Error>
pub fn execute(self) -> Result<Option<CollectionDocument<Col>>, Error>
Retrieves the document, if found/inserted.
sourcepub fn or_insert_with<F: EntryInsert<Col> + 'a + Unpin>(
self,
cb: F
) -> Entry<'a, 'name, Connection, Col, F, EU>
pub fn or_insert_with<F: EntryInsert<Col> + 'a + Unpin>( self, cb: F ) -> Entry<'a, 'name, Connection, Col, F, EU>
If an entry with the key doesn’t exist, cb
will be executed to provide
an initial document. This document will be saved before being returned.
sourcepub fn update_with<F: EntryUpdate<Col> + 'a + Unpin>(
self,
cb: F
) -> Entry<'a, 'name, Connection, Col, EI, F>
pub fn update_with<F: EntryUpdate<Col> + 'a + Unpin>( self, cb: F ) -> Entry<'a, 'name, Connection, Col, EI, F>
If an entry with the keys exists, cb
will be executed with the stored
value, allowing an opportunity to update the value. This new value will
be saved to the database before returning. If an error occurs during
update, cb
may be invoked multiple times, up to the
retry_limit
.
sourcepub const fn retry_limit(self, attempts: usize) -> Self
pub const fn retry_limit(self, attempts: usize) -> Self
The number of attempts to attempt updating the document using
update_with
before returning an error.
Auto Trait Implementations§
impl<'a, 'name, Connection, Col, EI, EU> RefUnwindSafe for Entry<'a, 'name, Connection, Col, EI, EU>where
Col: RefUnwindSafe,
Connection: RefUnwindSafe,
EI: RefUnwindSafe,
EU: RefUnwindSafe,
<Col as Collection>::PrimaryKey: RefUnwindSafe,
impl<'a, 'name, Connection, Col, EI, EU> Send for Entry<'a, 'name, Connection, Col, EI, EU>where
Connection: Sync,
impl<'a, 'name, Connection, Col, EI, EU> Sync for Entry<'a, 'name, Connection, Col, EI, EU>
impl<'a, 'name, Connection, Col, EI, EU> Unpin for Entry<'a, 'name, Connection, Col, EI, EU>
impl<'a, 'name, Connection, Col, EI, EU> UnwindSafe for Entry<'a, 'name, Connection, Col, EI, EU>where
Col: UnwindSafe,
Connection: RefUnwindSafe,
EI: UnwindSafe,
EU: UnwindSafe,
<Col as Collection>::PrimaryKey: UnwindSafe,
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