Skip to main content

OperationSchema

Struct OperationSchema 

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

Source

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.

Source

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.

Source

pub fn input(&self) -> &'a Schema<'a>

The input schema for this operation, to pass to a protocol’s serialize_request.

Source

pub fn output(&self) -> &'a Schema<'a>

The output schema for this operation, to pass to a protocol’s deserialize_response.

Source

pub fn errors(&self) -> &'a [&'a Schema<'a>]

The error structures the operation can return.

Trait Implementations§

Source§

impl<'a> Clone for OperationSchema<'a>

Source§

fn clone(&self) -> OperationSchema<'a>

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 Debug for OperationSchema<'_>

Source§

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

Shows shape IDs only, not the complete schemas.

Auto 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> 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> 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<Unshared, Shared> IntoShared<Shared> for Unshared
where Shared: FromUnshared<Unshared>,

Source§

fn into_shared(self) -> Shared

Creates a shared type from an unshared type.
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