pub struct PendingCollectionsOperation<'order_by> { /* private fields */ }
Expand description

Use ditto.store().collections() to query information about Ditto collections themselves.

They allow chaining of further collections-related functions. You can either call exec on the object to get an array of Collections as an immediate return value, or you can establish either a live query or a subscription, which both work over time.

A live query, established by calling observe_local, will notify you every time there’s a change in the collections that the device knows about.

A subscription, established by calling subscribe, will act as a signal to other peers that the device connects to that you would like to receive updates from them about the collections that they know about.

Typically, an app would set up a subscribe in some part of the application which is long-lived to ensure the device receives updates from the mesh. These updates will be automatically received and written into the local store. Elsewhere, where you need to use this data, an observe_local can be used to notify you of the data, and all subsequent changes to the data.

Implementations§

source§

impl<'order_by> PendingCollectionsOperation<'order_by>

source

pub fn limit(&mut self, limit: i32) -> &mut Self

Limit the number of documents that get returned when querying a collection for matching documents.

source

pub fn offset(&mut self, offset: u32) -> &mut Self

Offset the resulting set of matching documents. This is useful if you aren’t interested in the first N matching documents for one reason or another. For example, you might already have queried the collection and obtained the first 20 matching documents and so you might want to run the same query as you did previously but ignore the first 20 matching documents, and that is where you would use offset.

source

pub fn sort(&mut self, sort_param: Vec<COrderByParam<'order_by>>) -> &mut Self

Sort the documents that match the query provided in the preceding find-like function call.

Documents that are missing the field to sort by will appear at the beginning of the results when sorting in ascending order.

source

pub fn exec(&self) -> Result<Vec<Collection>, DittoError>

Execute the query generated by the preceding function chaining and return the list of matching documents. This occurs immediately.

source

pub fn subscribe(&self) -> Subscription

Enables you to subscribe to changes that occur on a collection. Having a subscription acts as a signal to others that you are interested in receiving updates when local or remote changes are made to documents that match the query generated by the chain of operations that precedes the call to subscribe. The returned Subscription object must be kept in scope for as long as you want to keep receiving updates.

source

pub fn observe_local<Handler>( &self, handler: Handler, ) -> Result<LiveQuery, DittoError>
where Handler: CollectionsEventHandler,

Enables you to listen for changes that occur on a collection. This won’t subscribe to receive changes made remotely by others and so it will only fire updates when a local change is made. If you want to receive remotely performed updates as well then also call subscribe with the relevant query. The returned LiveQuery object must be kept in scope for as long as you want the provided Handler to be called when an update occurs.

Auto Trait Implementations§

§

impl<'order_by> Freeze for PendingCollectionsOperation<'order_by>

§

impl<'order_by> RefUnwindSafe for PendingCollectionsOperation<'order_by>

§

impl<'order_by> Send for PendingCollectionsOperation<'order_by>

§

impl<'order_by> Sync for PendingCollectionsOperation<'order_by>

§

impl<'order_by> Unpin for PendingCollectionsOperation<'order_by>

§

impl<'order_by> UnwindSafe for PendingCollectionsOperation<'order_by>

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
§

impl<T> CompatExt for T

§

fn compat(self) -> Compat<T>

Applies the [Compat] adapter by value. Read more
§

fn compat_ref(&self) -> Compat<&T>

Applies the [Compat] adapter by shared reference. Read more
§

fn compat_mut(&mut self) -> Compat<&mut T>

Applies the [Compat] adapter by mutable reference. Read more
§

impl<T> FitForCBox for T

§

type CBoxWrapped = Box_<T>

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.

§

impl<T> ManuallyDropMut for T

§

type Ret = ManuallyDrop<T>

§

fn manually_drop_mut<'__>(&'__ mut self) -> &'__ mut ManuallyDrop<T>

§

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

§

fn to<T>(self) -> T
where Self: Into<T>,

Converts to T by calling Into<T>::into.
§

fn try_to<T>(self) -> Result<T, Self::Error>
where Self: TryInto<T>,

Tries to convert to T by calling TryInto<T>::try_into.
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
§

impl<F> ZeroSizedElseWrathOfTheGඞds for F