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>
impl Operation<Value>
Sourcepub fn action(
system_id: impl Into<String>,
method: Method,
path_template: impl Into<String>,
) -> Self
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>
impl<Out> Operation<Out>
Sourcepub fn retry(self, schedule: RetrySchedule) -> Self
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.
Sourcepub fn retry_on(self, statuses: impl IntoIterator<Item = StatusCode>) -> Self
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.
Sourcepub fn timeout(self, timeout: Duration) -> Self
pub fn timeout(self, timeout: Duration) -> Self
Sets a per-request timeout for this call, overriding the client default.
Sourcepub fn on_success<F: Fn(&CallResponse) + Send + Sync + 'static>(
self,
hook: F,
) -> Self
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.
Sourcepub fn on_error<F: Fn(&Error) + Send + Sync + 'static>(self, hook: F) -> Self
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.
Sourcepub fn returns<Out2>(self) -> Operation<Out2>
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.
Sourcepub fn with_path<P: Serialize>(self, path: &P) -> Result<Self, Error>
pub fn with_path<P: Serialize>(self, path: &P) -> Result<Self, Error>
Fills the path template’s {{name}} placeholders from the typed path
part.
Sourcepub fn with_query<Q: Serialize>(self, query: &Q) -> Result<Self, Error>
pub fn with_query<Q: Serialize>(self, query: &Q) -> Result<Self, Error>
Attaches the typed query part; serde lowers it to query parameters.
Sourcepub fn with_headers<H: Serialize>(self, headers: &H) -> Result<Self, Error>
pub fn with_headers<H: Serialize>(self, headers: &H) -> Result<Self, Error>
Attaches the typed headers part as request headers.
Sourcepub fn with_body<B: Serialize>(self, body: &B) -> Result<Self, Error>
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.
Sourcepub fn with_routed<I: Serialize>(
self,
input: &I,
routing: &Routing,
) -> Result<Self, Error>
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.
Sourcepub fn raw_body(self, body: impl Into<Bytes>) -> Self
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.
Sourcepub fn merge_body(self, extra: Value) -> Result<Self, Error>
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.
Sourcepub fn merge_query(self, extra: Value) -> Self
pub fn merge_query(self, extra: Value) -> Self
Merges extra parameters on top of the typed query.
Sourcepub fn merge_headers(self, extra: Value) -> Self
pub fn merge_headers(self, extra: Value) -> Self
Merges extra headers on top of the typed headers, matching names as
HTTP does, without case; a null one unsets that header, as
merge_query does for a query parameter.
Sourcepub fn remove_header(self, name: &str) -> Self
pub fn remove_header(self, name: &str) -> Self
Removes a header — e.g. to drop one injected from a busted const.
Sourcepub fn remove_query(self, name: &str) -> Self
pub fn remove_query(self, name: &str) -> Self
Removes a query parameter.