pub struct OperationSchema<'a> { /* private fields */ }Expand description
The identity and schemas of one Smithy operation.
An operation is not itself serialized, so it has no Schema; this descriptor relates the
operation’s shape ID to the schemas a protocol needs to call it: the input, the output, and
the errors it can return.
The descriptor borrows everything, so it is cheap to construct and to clone. It is built
with OperationSchema::builder, whose methods are const, so it can be declared as a
static alongside generated schemas:
use aws_smithy_schema::{shape_id, OperationSchema, Schema, ShapeType};
static INPUT: Schema<'static> =
Schema::new_struct(shape_id!("com.example", "GetThingInput"), ShapeType::Structure, &[]);
static OUTPUT: Schema<'static> =
Schema::new_struct(shape_id!("com.example", "GetThingOutput"), ShapeType::Structure, &[]);
static NOT_FOUND: Schema<'static> =
Schema::new_struct(shape_id!("com.example", "NotFound"), ShapeType::Structure, &[]);
static GET_THING: OperationSchema<'static> =
OperationSchema::builder(shape_id!("com.example", "GetThing"))
.input(&INPUT)
.output(&OUTPUT)
.errors(&[&NOT_FOUND])
.build();
assert_eq!(GET_THING.id().as_str(), "com.example#GetThing");
assert_eq!(GET_THING.input().shape_id().as_str(), "com.example#GetThingInput");
assert_eq!(GET_THING.errors().len(), 1);§Input and output schemas
Protocols read operation-level behavior, such as the @http trait and body hints, from the
input schema, and S3’s unwrapped XML output from the output schema. The input and output
schemas of a descriptor are therefore specific to the operation: when two operations share
an input structure, each has its own input schema with that structure’s ID, members, and
traits plus its own operation-level behavior.
§Errors
errors are the operation’s errors in the context the descriptor was built
for. For an operation of a service, that is the service’s common errors followed by the
operation’s own, without duplicates. Without a service, it is the operation’s own errors.
§Lifetimes
A descriptor cannot outlive the schemas it references:
use aws_smithy_schema::{shape_id, OperationSchema, Schema, ShapeType};
let operation = {
let unit = Schema::new(shape_id!("smithy.api", "Unit"), ShapeType::Structure);
OperationSchema::builder(shape_id!("com.example", "Op"))
.input(&unit)
.build()
};Implementations§
Source§impl<'a> OperationSchema<'a>
impl<'a> OperationSchema<'a>
Sourcepub const fn builder(id: ShapeId<'a>) -> OperationSchemaBuilder<'a>
pub const fn builder(id: ShapeId<'a>) -> OperationSchemaBuilder<'a>
A builder for the descriptor of the operation id.
The input and output default to prelude::UNIT, as in a Smithy model that omits
them, and the errors default to none.
Sourcepub fn id(&self) -> ShapeId<'a>
pub fn id(&self) -> ShapeId<'a>
The operation’s shape ID.
Returned by value: a ShapeId only borrows its strings, so this does not allocate,
and the result is not tied to the lifetime of the descriptor value itself.
Sourcepub fn input(&self) -> &'a Schema<'a>
pub fn input(&self) -> &'a Schema<'a>
The input schema for this operation, to pass to a protocol’s serialize_request.
Trait Implementations§
Source§impl<'a> Clone for OperationSchema<'a>
impl<'a> Clone for OperationSchema<'a>
Source§fn clone(&self) -> OperationSchema<'a>
fn clone(&self) -> OperationSchema<'a>
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreAuto Trait Implementations§
impl<'a> !RefUnwindSafe for OperationSchema<'a>
impl<'a> !UnwindSafe for OperationSchema<'a>
impl<'a> Freeze for OperationSchema<'a>
impl<'a> Send for OperationSchema<'a>
impl<'a> Sync for OperationSchema<'a>
impl<'a> Unpin for OperationSchema<'a>
impl<'a> UnsafeUnpin for OperationSchema<'a>
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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