pub struct WithDocResult<T> {
pub value: T,
pub actor_result: DocActorResult,
}Expand description
Result of a document operation that includes both the closure result and any side effects.
When modifying a document via with_document, the operation may generate side effects
like storage operations (saving changes) or messages to be sent to connected peers.
This type encapsulates both the result of the user’s closure and the side effects
that need to be executed.
§Type Parameters
T- The type returned by the closure passed towith_document
§Example
let result = actor.with_document(|doc| {
// Modify document and return some value
doc.put_object(automerge::ROOT, "key", "value").unwrap()
})?;
// Access the closure result
let object_id = result.value;
// Execute any side effects
for io_task in result.actor_result.io_tasks {
// Execute storage operations
}
for message in result.actor_result.outgoing_messages {
// Send messages to main Samod
}Fields§
§value: TThe result returned by the closure passed to with_document
actor_result: DocActorResultAny side effects generated by the document operation (IO tasks, messages, etc.)
Implementations§
Source§impl<T> WithDocResult<T>
impl<T> WithDocResult<T>
Sourcepub fn with_side_effects(value: T, actor_result: DocActorResult) -> Self
pub fn with_side_effects(value: T, actor_result: DocActorResult) -> Self
Creates a new result with the given value and actor result
Trait Implementations§
Auto Trait Implementations§
impl<T> Freeze for WithDocResult<T>where
T: Freeze,
impl<T> RefUnwindSafe for WithDocResult<T>where
T: RefUnwindSafe,
impl<T> Send for WithDocResult<T>where
T: Send,
impl<T> Sync for WithDocResult<T>where
T: Sync,
impl<T> Unpin for WithDocResult<T>where
T: Unpin,
impl<T> UnwindSafe for WithDocResult<T>where
T: 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
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
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