Struct dittolive_ditto::store::collection::pending_id_specific_operation::PendingIdSpecificOperation
source · [−]pub struct PendingIdSpecificOperation { /* private fields */ }
Expand description
These objects are returned when using
Collection::find_by_id
functionality.
You can either call exec
on the object to get 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
an update to the document with the Id you provided in the preceding
Collection::find_by_id
call. A subscription,
established by calling subscribe
, will act as a
signal to other peers that you would like to receive updates from them about the document with
the Id you provided in the preceding
Collection::find_by_id
call. Update and remove
functionality is also exposed through this object.
Implementations
sourceimpl PendingIdSpecificOperation
impl PendingIdSpecificOperation
sourcepub fn subscribe(&self) -> Subscription
pub fn subscribe(&self) -> Subscription
Enables you to subscribe to changes that occur in relation to a document. Having a
subscription acts as a signal to other peers that you are interested in receiving updates
when local or remote changes are made to the relevant document. The returned
Subscription
object must be kept in scope for as long as
you want to keep receiving updates.
Panics
Panics if Ditto has been closed.
sourcepub fn remove(&self) -> Result<(), DittoError>
pub fn remove(&self) -> Result<(), DittoError>
Remove the document with the matching Id.
sourcepub fn evict(&self) -> Result<(), DittoError>
pub fn evict(&self) -> Result<(), DittoError>
Evict the document with the matching Id.
sourcepub fn exec(&self) -> Result<BoxedDocument, DittoError>
pub fn exec(&self) -> Result<BoxedDocument, DittoError>
Execute the find operation to return the document with the matching Id.
sourcepub fn observe_local<Handler>(
&self,
handler: Handler
) -> Result<LiveQuery, DittoError>where
Handler: SingleDocumentEventHandler,
pub fn observe_local<Handler>(
&self,
handler: Handler
) -> Result<LiveQuery, DittoError>where
Handler: SingleDocumentEventHandler,
Enables you to listen for changes that occur in relation to a document. 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 call
subscribe
separately after another
find_by_id
call that references the same
document Id.
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.
sourcepub fn update<Updater>(
&self,
updater: Updater
) -> Result<Vec<UpdateResult>, DittoError>where
Updater: Fn(Option<&mut BoxedDocument>),
pub fn update<Updater>(
&self,
updater: Updater
) -> Result<Vec<UpdateResult>, DittoError>where
Updater: Fn(Option<&mut BoxedDocument>),
Update the document with the matching Id.
updater
: anFn
which will be called on the selected document, if found
sourcepub fn update_doc<T>(&self, new_value: &T) -> Result<(), DittoError>where
T: Serialize,
pub fn update_doc<T>(&self, new_value: &T) -> Result<(), DittoError>where
T: Serialize,
Replaces the matching document with the provided value.
new_value
: A newSerializable
which will replace the found document
Note this actually follows “upsert” rules and will insert a document if no document is found
with the given DocumentId
.
Auto Trait Implementations
impl RefUnwindSafe for PendingIdSpecificOperation
impl Send for PendingIdSpecificOperation
impl Sync for PendingIdSpecificOperation
impl Unpin for PendingIdSpecificOperation
impl UnwindSafe for PendingIdSpecificOperation
Blanket Implementations
sourceimpl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<T> CompatExt for T
impl<T> CompatExt for T
fn compat_ref(&self) -> Compat<&T>
fn compat_ref(&self) -> Compat<&T>
Compat
] adapter by shared reference. Read morefn compat_mut(&mut self) -> Compat<&mut T>
fn compat_mut(&mut self) -> Compat<&mut T>
Compat
] adapter by mutable reference. Read more