Skip to main content

Operation

Struct Operation 

Source
pub struct Operation<Out = Value> { /* private fields */ }
Expand description

A declarative description of an action invocation.

You describe what you want — which action (system_id), the request shape, and the retry policy — and the engine (ConnectionScope::run) resolves how to execute it. The action’s verb and path are part of the description; once discovery lands they are filled from the action itself rather than supplied by hand.

Implementations§

Source§

impl Operation<Value>

Source

pub fn action( system_id: impl Into<String>, method: Method, path_template: impl Into<String>, ) -> Self

Starts a typed action operation from its system_id, HTTP method, and path template. Envelope parts are attached with the with_* setters, which take the typed parts directly — the envelope contract is the typed fields passed by name, not keys fished out of a serialized blob. Output defaults to Value; generated actions re-tag it via Operation::returns.

Source§

impl<Out> Operation<Out>

Source

pub fn retry(self, schedule: RetrySchedule) -> Self

Declares the retry policy for this operation, overriding the client default. Part of the description — the engine resolves it.

Source

pub fn retry_on(self, statuses: impl IntoIterator<Item = StatusCode>) -> Self

Adds HTTP status codes that should be retried for this call, on top of the always-retried transient set (network errors, 5xx, 429). HTTP-only — status classification has no meaning outside an API call.

Source

pub fn timeout(self, timeout: Duration) -> Self

Sets a per-request timeout for this call, overriding the client default.

Source

pub fn on_success<F: Fn(&CallResponse) + Send + Sync + 'static>( self, hook: F, ) -> Self

Registers a per-call success hook, run in addition to the client’s global on_success.

Source

pub fn on_error<F: Fn(&Error) + Send + Sync + 'static>(self, hook: F) -> Self

Registers a per-call error hook, run in addition to the client’s global on_error.

Source

pub fn returns<Out2>(self) -> Operation<Out2>

Re-tags the operation’s output type. Generated actions attach the io_schema’s Output; callers can override a wrong synced output.

Source

pub fn with_path<P: Serialize>(self, path: &P) -> Result<Self, Error>

Fills the path template’s {{name}} placeholders from the typed path part.

Source

pub fn with_query<Q: Serialize>(self, query: &Q) -> Result<Self, Error>

Attaches the typed query part; serde lowers it to query parameters.

Source

pub fn with_headers<H: Serialize>(self, headers: &H) -> Result<Self, Error>

Attaches the typed headers part as request headers.

Source

pub fn with_body<B: Serialize>(self, body: &B) -> Result<Self, Error>

Serializes the typed body part as the request payload. An omitted optional body (Option<Body> left unset) serializes to the literal null; treat that as “no body” and leave the payload empty so the engine omits it rather than sending null bytes upstream.

Source

pub fn with_routed<I: Serialize>( self, input: &I, routing: &Routing, ) -> Result<Self, Error>

Distributes a generated action’s flat input into its request parts: an unkeyed route supplies the whole part, a keyed route then sets one entry of its part, and a field the input leaves out is skipped. A required part with nothing set is sent as {}, and the path template is always rendered, so a missing path value fails here instead of going upstream.

Source

pub fn raw_body(self, body: impl Into<Bytes>) -> Self

Sets the request body to raw bytes, for non-JSON payloads. The typed with_body is preferred for action calls.

Source

pub fn merge_body(self, extra: Value) -> Result<Self, Error>

Merges extra fields into the request body, on top of the typed body — the escape hatch for attributes a stale or incomplete io_schema omits.

Source

pub fn merge_query(self, extra: Value) -> Self

Merges extra parameters on top of the typed query.

Source

pub fn merge_headers(self, extra: Value) -> Self

Merges extra headers on top of the typed headers.

Source

pub fn remove_header(self, name: &str) -> Self

Removes a header — e.g. to drop one injected from a busted const.

Source

pub fn remove_query(self, name: &str) -> Self

Removes a query parameter.

Source

pub fn system_id(&self) -> &str

The action’s system id (sent as X-One-Action-Id).

Source

pub fn method(&self) -> &Method

The resolved HTTP method.

Source

pub fn path(&self) -> &str

The resolved upstream path, with placeholders filled in.

Source

pub fn query(&self) -> &Value

The resolved query parameters.

Source

pub fn headers(&self) -> &BTreeMap<String, String>

The resolved request headers, including injected const headers.

Source

pub fn body(&self) -> &Bytes

The serialized request body.

Trait Implementations§

Source§

impl<Out> Clone for Operation<Out>

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

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

Performs copy-assignment from source. Read more
Source§

impl<Out> Debug for Operation<Out>

Source§

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

Formats the value using the given formatter. Read more
Source§

impl<Out> IntoOperation for Operation<Out>

Source§

type Output = Out

The type the response decodes to.
Source§

fn into_operation(self) -> Result<Self, Error>

Builds the operation, failing when the input does not validate.

Auto Trait Implementations§

§

impl<Out = Value> !Freeze for Operation<Out>

§

impl<Out = Value> !RefUnwindSafe for Operation<Out>

§

impl<Out = Value> !UnwindSafe for Operation<Out>

§

impl<Out> Forget for Operation<Out>

§

impl<Out> Move for Operation<Out>

§

impl<Out> Send for Operation<Out>
where RawVecInner: Send, BoxRaw<[u8]>: Send, NodeRef<Owned, String, Value, LeafOrInternal>: Send, BoxRaw<(String, Value)>: Send, NodeRef<Owned, String, String, LeafOrInternal>: Send, BoxRaw<(String, String)>: Send, Bytes: Send, NonZero<u16>: Send, Arc<dyn Fn(&CallResponse) + Sync + Send>: Send, Arc<dyn Fn(&Error) + Sync + Send>: Send,

§

impl<Out> Sync for Operation<Out>
where RawVecInner: Sync, BoxRaw<[u8]>: Sync, NodeRef<Owned, String, Value, LeafOrInternal>: Sync, BoxRaw<(String, Value)>: Sync, NodeRef<Owned, String, String, LeafOrInternal>: Sync, BoxRaw<(String, String)>: Sync, Bytes: Sync, NonZero<u16>: Sync, Arc<dyn Fn(&CallResponse) + Sync + Send>: Sync, Arc<dyn Fn(&Error) + Sync + Send>: Sync,

§

impl<Out> Unpin for Operation<Out>
where *const u8 is !null: Unpin, Box<[u8]>: Unpin, *const LeafNode<String, Value> is !null: Unpin, Box<(String, Value)>: Unpin, *const LeafNode<String, String> is !null: Unpin, Box<(String, String)>: Unpin, *const u8: Unpin, Align8<*mut ()>: Unpin, &'static Vtable: Unpin, NonZero<u16>: Unpin, Arc<dyn Fn(&CallResponse) + Sync + Send>: Unpin, Arc<dyn Fn(&Error) + Sync + Send>: Unpin,

§

impl<Out> UnsafeUnpin for Operation<Out>

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> 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> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
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 = !

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