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,

source

pub fn execute(self) -> Result<Option<CollectionDocument<Col>>, Error>

Retrieves the document, if found/inserted.

source

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.

source

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.

source

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>

§

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>
where Connection: Sync, EI: Sync, EU: Sync,

§

impl<'a, 'name, Connection, Col, EI, EU> Unpin for Entry<'a, 'name, Connection, Col, EI, EU>
where <Col as Collection>::PrimaryKey: Unpin,

§

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> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> Same for T

§

type Output = T

Should always be Self
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V

§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more