pub struct ActionCx { /* private fields */ }Expand description
Deterministic services available while an action applies.
Everything here is a pure function of the action and the document it was authored against, so the origin and every replaying replica compute the same ids and see the same time.
Implementations§
Source§impl ActionCx
impl ActionCx
Sourcepub fn remove_item(&mut self)
pub fn remove_item(&mut self)
Remove the item the item method running now acts on
(#[action(item = field)] with the item as its first parameter): what
it changed of the item is let go with it. The item is read and removed
alone, never the collection holding it, however many items that holds.
Sourcepub fn for_apply(doc: &Doc, payload: &[u8], now_ms: i64) -> Self
pub fn for_apply(doc: &Doc, payload: &[u8], now_ms: i64) -> Self
A context seeded from the document’s heads and actor (both pinned by the executor) and the action’s own payload.
Inside an ActionGroup the group’s seed and the
member’s position stand in for the heads, which a member cannot read
without committing the members before it as separate changes.
Sourcepub fn for_write(doc: &Doc, payload: &[u8]) -> Self
pub fn for_write(doc: &Doc, payload: &[u8]) -> Self
A context for ids minted part-way through an action that has already
written: seeded like Self::for_apply but from the heads the action
started from, so reading them does not commit its writes so far as a
separate change.
Sourcepub fn is_preview(&self) -> bool
pub fn is_preview(&self) -> bool
Whether the runtime is evaluating compensation on a private record copy or replaying an existing change. Neither may issue host-local approvals or repeat outside effects; only a new invocation admits those.
Sourcepub fn named(&mut self, id: impl Into<String>, label: impl Into<String>)
pub fn named(&mut self, id: impl Into<String>, label: impl Into<String>)
Name the item this change is about, when the record holds no item for
it: the file a device will write, the entry the action queued. History
says the change by label, which is what a person reads, under id:
the id the change carries, which need not be a resource the app can
open. A change that makes or edits an item of the record itself says
so already, and keeps that item.
Sourcepub fn acting_name(&self) -> String
pub fn acting_name(&self) -> String
The name software acting for someone (an agent, an app) acted under, as the host that admitted it named it; empty for a person.
Sourcepub fn appearance(&self) -> Option<Appearance>
pub fn appearance(&self) -> Option<Appearance>
The name and avatar a bot showed for this action instead of its own,
as the envelope pinned it; None for anyone else’s action.
Sourcepub fn invoked_by(&self) -> Option<Acting>
pub fn invoked_by(&self) -> Option<Acting>
Who invoked the action (a person, an agent, an automation), as the envelope pinned it.
Sourcepub fn now_ms(&self) -> i64
pub fn now_ms(&self) -> i64
When the action was authored, in milliseconds since the Unix epoch, as read once on the origin.
Who the action is by: the person or agent that invoked it, the same
id that member’s own views read as me. Pinned with the action
like its time, so every replica reads the same author; the payload
need not carry it. None for an action applied with no invoker
(an edit written straight into a document outside the host).
Sourcepub const fn invocation(&self) -> Option<InvocationId>
pub const fn invocation(&self) -> Option<InvocationId>
The invocation admitted by the action API, pinned in the action
envelope so origin and replay observe the same correlation identity.
This is not caller authority; use Self::author for that.
Trait Implementations§
Auto Trait Implementations§
impl Forget for ActionCx
impl Freeze for ActionCx
impl Move for ActionCx
impl RefUnwindSafe for ActionCx
impl Send for ActionCx
impl Sync for ActionCx
impl Unpin for ActionCx
impl UnsafeUnpin for ActionCx
impl UnwindSafe for ActionCx
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
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> ⓘ
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> ⓘ
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