Skip to main content

Operation

Struct Operation 

Source
pub struct Operation {
    pub name: &'static str,
    pub method: Method,
    pub path: &'static str,
    pub effect: Effect,
    pub accepts: Option<&'static str>,
    pub answers: &'static str,
    pub query: &'static [Declared],
    pub body: &'static [Declared],
    pub image_path_field: Option<&'static str>,
}
Expand description

One public operation: what it is called, how it is reached, and what it does.

Fields§

§name: &'static str

The operation’s own name. For a mutating operation this is the spelling the contracts’ own PrintAction tags that variant with.

§method: Method

The method it is reached by.

§path: &'static str

Its path beneath VERSION_PREFIX.

§effect: Effect

What it does.

§accepts: Option<&'static str>

The media type it takes a body in, when it takes one.

§answers: &'static str

The media type it answers in.

§query: &'static [Declared]

The values it takes after the question mark.

§body: &'static [Declared]

The values it takes in its body, for an operation whose body is not one action of the vocabulary. A mutating operation declares none here: its body is the PrintAction variant it names, read from the contracts themselves by Operation::request.

§image_path_field: Option<&'static str>

The field of its answer carrying an absolute path to a materialized image, when its answer carries one.

Every image answer this server gives is a path on this server’s own filesystem and no route of it answers image bytes, so a consumer reading this field is reading which of its values names a file it may not be able to open. Declared here rather than discovered, because what a consumer owes such a field is a failure of its own.

Implementations§

Source§

impl Operation

Source

pub fn full_path(&self) -> String

Its whole path, including the versioned prefix.

Source

pub const fn action_kind(&self) -> Option<ActionKind>

Which action this operation asks for, when it asks for one.

Source

pub const fn is_mutating(&self) -> bool

Whether this operation changes something.

Asking the machine for an action and replacing the manifest a print runs under are both changes, and both carry a reason. What separates them is whether the policy has anything to rule on — not whether the caller has to say why.

Source

pub fn request(&self) -> Vec<Parameter>

Every value a request to this operation carries, and where it carries it.

The body of a mutating operation is not written out anywhere: it is the fields the contracts’ own PrintAction declares for the variant this operation names, read from that type’s own schema. A variant that gains a field gains it here without this file changing, which is what stops a consumer building a request surface from drifting from the vocabulary.

§Panics

Panics when the contracts declare no variant this operation names, which is a declared list and a closed type that have come apart.

Source

pub fn request_shapes(&self) -> Vec<(Parameter, Value)>

Every value a request to this operation carries, with its own shape.

Operation::request answers what a command line needs — a name, a place and a kind. This answers what a typed consumer needs beside that: the shape of each value, as a schema referring to the contracts’ own types by name where the value is one of theirs. structured says a manifest is a document; {"$ref": "#/$defs/JobManifest"} says which document, which is the difference between a generated client that types it and one that takes anything.

The order is Operation::request’s own, so the two can be read side by side.

§Panics

Panics when the contracts declare no variant this operation names, which is a declared list and a closed type that have come apart.

Source

pub const fn answers_with(&self) -> &'static [Answer]

Every answer this operation can produce.

A read answers what it read. An operation asking for an action answers that as well as the policy’s own rejection, which is an answer rather than a transport failure: it carries the reason, the value asked for and the range allowed.

Source

pub fn response_schema(&self, answer: Answer) -> Value

The schema of one answer this operation produces.

A rejection is the same shape as an acceptance and deliberately so: the answer to a rejected action is the action record carrying the policy’s own decision, rather than a second document a caller has to know about.

§Panics

Panics when this operation is not one this server serves an answer shape for, which is a declared list and a router that have come apart.

Trait Implementations§

Source§

impl Clone for Operation

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 Copy for Operation

Source§

impl Debug for Operation

Source§

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

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

impl Eq for Operation

Source§

impl PartialEq for Operation

Source§

fn eq(&self, other: &Self) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for Operation

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> AsOut<T> for T
where T: Copy,

Source§

fn as_out(&mut self) -> Out<'_, T>

Returns an out reference to self.
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<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

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

Source§

fn __clone_box(&self, _: Private) -> *mut ()

Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

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

Source§

fn from_ref(input: &T) -> T

Converts to this type from a reference to the input type.
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> 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> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

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