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>,
pub printer_wide: Option<&'static Operation>,
}Expand description
One public operation: what it is called, how it is reached, and what it does.
Fields§
§name: &'static strThe operation’s own name. For a mutating operation this is the spelling
the contracts’ own PrintAction tags that variant with.
method: MethodThe method it is reached by.
path: &'static strIts path beneath VERSION_PREFIX.
effect: EffectWhat it does.
accepts: Option<&'static str>The media type it takes a body in, when it takes one.
answers: &'static strThe 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 or SpoolCommand 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.
printer_wide: Option<&'static Operation>The operation a request to this one is made to instead when it names no print, for a read of one print that has a form for the printer as a whole.
The command made from this operation takes its print as optional, and the operation named here has no command of its own: it is reached through this one’s. It takes no value this operation does not, less the print.
Implementations§
Source§impl Operation
impl Operation
Sourcepub const fn action_kind(&self) -> Option<ActionKind>
pub const fn action_kind(&self) -> Option<ActionKind>
Which print action this operation asks for, when it asks for one.
Sourcepub const fn command_kind(&self) -> Option<ActionKind>
pub const fn command_kind(&self) -> Option<ActionKind>
Which spool command this operation asks for, when it asks for one.
Sourcepub const fn granted_as(&self) -> Option<ActionKind>
pub const fn granted_as(&self) -> Option<ActionKind>
Which action of either vocabulary this operation asks for, when it asks for one: the kind the envelope grants it under.
Sourcepub const fn recovery_kind(&self) -> Option<RecoveryActionKind>
pub const fn recovery_kind(&self) -> Option<RecoveryActionKind>
Which recovery action this operation asks for, when it asks for one: the kind the recovery grants rule on.
Sourcepub const fn is_mutating(&self) -> bool
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.
Sourcepub fn request(&self) -> Vec<Parameter>
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 or SpoolCommand declares for
the variant this operation names, read from that type’s own schema,
less the tag and any value the path already carries. 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.
Sourcepub fn request_shapes(&self) -> Vec<(Parameter, Value)>
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.
Sourcepub const fn answers_with(&self) -> &'static [Answer]
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.
Sourcepub fn response_schema(&self, answer: Answer) -> Value
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§
impl Copy for Operation
impl Eq for Operation
impl StructuralPartialEq for Operation
Auto Trait Implementations§
impl Freeze for Operation
impl RefUnwindSafe for Operation
impl Send for Operation
impl Sync for Operation
impl Unpin for Operation
impl UnsafeUnpin for Operation
impl UnwindSafe for Operation
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
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