Skip to main content

ActionCx

Struct ActionCx 

Source
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

Source

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.

Source

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.

Source

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.

Source

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.

Source

pub fn id(&mut self) -> Id

A fresh id, unique to this action and stable under replay.

Source

pub fn uuid(&mut self) -> Uuid

A fresh UUID, unique to this action and stable under replay.

Source

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.

Source

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.

Source

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.

Source

pub fn invoked_by(&self) -> Option<Acting>

Who invoked the action (a person, an agent, an automation), as the envelope pinned it.

Source

pub fn now_ms(&self) -> i64

When the action was authored, in milliseconds since the Unix epoch, as read once on the origin.

Source

pub fn author(&self) -> Option<&MemberId>

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).

Source

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§

Source§

impl Debug for ActionCx

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

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.

Source§

impl<T> Instrument for T

Source§

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

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

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> IntoEither for T

Source§

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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
where F: FnOnce(&Self) -> bool,

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
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

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

Source§

type Error = !

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

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

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

Source§

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.
Source§

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

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

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
Source§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

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