Module aws_smithy_http_server::service

source ·
Expand description

The shape of a Smithy service is modelled by the ServiceShape trait. Its associated types ServiceShape::ID, ServiceShape::VERSION, ServiceShape::Protocol, and ServiceShape::Operations map to the services Shape ID, the version field, the applied protocol trait (see protocol module), and the operations field.

We generate an implementation on this for every service struct (exported from the root of the generated crate).

As stated in the operation module documentation we also generate marker structs for OperationShape, these are coupled to the S: ServiceShape via the ContainsOperation trait.

The model

@restJson1
service Shopping {
    version: "1.0",
    operations: [
        GetShopping,
        PutShopping
    ]
}

is identified with the implementation

// For more information on these marker structs see `OperationShape`
struct GetShopping;
struct PutShopping;

// This is a generated enumeration of all operations.
#[derive(PartialEq, Eq, Clone, Copy)]
pub enum Operation {
    GetShopping,
    PutShopping
}

impl ServiceShape for Shopping {
    const ID: ShapeId = ShapeId::new("namespace#Shopping", "namespace", "Shopping");
    const VERSION: Option<&'static str> = Some("1.0");
    type Protocol = RestJson1;
    type Operations = Operation;
}

impl ContainsOperation<GetShopping> for Shopping {
    const VALUE: Operation = Operation::GetShopping;
}

impl ContainsOperation<PutShopping> for Shopping {
    const VALUE: Operation = Operation::PutShopping;
}

Traits§