Skip to main content

ObjectRef

Struct ObjectRef 

pub struct ObjectRef { /* private fields */ }
Expand description

A key of an object type, to call from outside workflow code.

Implementations§

§

impl ObjectRef

pub fn id(&self) -> String

The key’s workflow ID (<type>/<key>).

pub fn key(&self) -> &str

pub fn call<'a, A: Serialize + 'a, R: DeserializeOwned + 'a>( &'a self, handler: &'a str, arg: &'a A, ) -> Op<CallOptions, impl Make<CallOptions, Output = Result<R>, Fut = impl Future<Output = Result<R>> + 'a> + 'a> ⓘ

Calls a handler and waits for its durable result. Without an ID a retry is a new call; with .id(id), calls with the same ID run once, and every one gets the recorded result.

pub async fn call_raw( &self, handler: &str, arg: Payload, id: &str, ) -> Result<(Status, Payload)>

pub fn send<'a, A: Serialize + 'a>( &'a self, handler: &'a str, arg: &'a A, ) -> Op<CallOptions, impl Make<CallOptions, Output = Result<()>, Fut = impl Future<Output = Result<()>> + 'a> + 'a> ⓘ

Calls a handler without waiting for its result: resolves once the call is accepted (durable, and its handler started). .id(id) makes a retried send run once.

pub async fn edit_state(&self, edit: &Value) -> Result<Value>

Edits the state from outside its handlers (edit): an exclusive call, so it waits for the key and commits as a handler’s writes do. Returns {"version", "changed"}.

pub async fn set_state<V: Serialize>( &self, field: &str, value: &V, ) -> Result<Value>

Sets one field of the state.

pub async fn patch_state(&self, ops: &Value) -> Result<Value>

Applies a JSON Patch (RFC 6902) to the state as one JSON object.

pub async fn clear_state(&self, field: Option<&str>) -> Result<Value>

Clears one field, or (None) the whole state; the key remains.

pub async fn state(&self) -> Result<Value>

The committed state, a JSON object ({} for a key never called). Answered once it is durable.

pub async fn describe(&self) -> Result<RunDetail>

The key’s run: its journal, state and pending calls. Error::NotFound for a key never called.

pub async fn delete(&self) -> Result<()>

Deletes the key: its run ends and its state goes with it. The next call starts with empty state.

Trait Implementations§

§

impl Clone for ObjectRef

§

fn clone(&self) -> ObjectRef

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
§

impl Debug for ObjectRef

§

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

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

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

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

Source§

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>,

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.