pub trait ClientProtocolInner:
Send
+ Sync
+ Debug {
type Request;
type Response;
// Required methods
fn protocol_id(&self) -> &ShapeId;
fn serialize_request(
&self,
input: &dyn SerializableStruct,
input_schema: &Schema,
endpoint: &str,
cfg: &ConfigBag,
) -> Result<Self::Request, SerdeError>;
fn deserialize_response<'a>(
&self,
response: &'a Self::Response,
output_schema: &Schema,
cfg: &ConfigBag,
) -> Result<Box<dyn ShapeDeserializer + 'a>, SerdeError>;
fn update_endpoint(
&self,
request: &mut Self::Request,
endpoint: &Endpoint,
cfg: &ConfigBag,
) -> Result<(), SerdeError>;
// Provided method
fn payload_codec(&self) -> Option<&dyn DynCodec> { ... }
}Expand description
Statically-dispatched client protocol trait — the one implementors write.
Request and Response are associated types so a protocol can target any transport
(HTTP, MQTT, Unix-socket, in-memory, …). For the common HTTP case, set both to
aws_smithy_runtime_api::http::Request / Response.
Callers who need to store a protocol behind dyn (e.g., in a [ConfigBag] for
runtime swapping) should use the object-safe ClientProtocol trait instead.
Every ClientProtocolInner is automatically a
ClientProtocol<Self::Request, Self::Response> via a blanket impl, so implementors
never write ClientProtocol manually.
See apply_http_endpoint for the canonical HTTP implementation of
update_endpoint.
§Lifecycle
Instances are immutable and thread-safe. They are typically created once and shared across all requests for a client.
Required Associated Types§
Required Methods§
Sourcefn protocol_id(&self) -> &ShapeId
fn protocol_id(&self) -> &ShapeId
Returns the Smithy shape ID of this protocol.
Sourcefn serialize_request(
&self,
input: &dyn SerializableStruct,
input_schema: &Schema,
endpoint: &str,
cfg: &ConfigBag,
) -> Result<Self::Request, SerdeError>
fn serialize_request( &self, input: &dyn SerializableStruct, input_schema: &Schema, endpoint: &str, cfg: &ConfigBag, ) -> Result<Self::Request, SerdeError>
Serializes an operation input into a request message.
Sourcefn deserialize_response<'a>(
&self,
response: &'a Self::Response,
output_schema: &Schema,
cfg: &ConfigBag,
) -> Result<Box<dyn ShapeDeserializer + 'a>, SerdeError>
fn deserialize_response<'a>( &self, response: &'a Self::Response, output_schema: &Schema, cfg: &ConfigBag, ) -> Result<Box<dyn ShapeDeserializer + 'a>, SerdeError>
Deserializes a response message, returning a boxed ShapeDeserializer over
the response body.
The deserializer reads only body members. Callers that also need to read transport-bound members (HTTP headers, status code) do that directly in generated code before consuming the deserializer.
Sourcefn update_endpoint(
&self,
request: &mut Self::Request,
endpoint: &Endpoint,
cfg: &ConfigBag,
) -> Result<(), SerdeError>
fn update_endpoint( &self, request: &mut Self::Request, endpoint: &Endpoint, cfg: &ConfigBag, ) -> Result<(), SerdeError>
Updates a previously serialized request with a resolved endpoint.
Required by SEP requirement 7. The orchestrator calls this after endpoint
resolution, which happens after serialize_request.
HTTP protocols should implement this as:
apply_http_endpoint(request, endpoint, cfg)(See apply_http_endpoint.) Non-HTTP protocols implement the transport’s
equivalent.
Provided Methods§
Sourcefn payload_codec(&self) -> Option<&dyn DynCodec>
fn payload_codec(&self) -> Option<&dyn DynCodec>
Returns the codec used for payload (de)serialization, if any.
See DynCodec for why the codec is exposed
through the object-safe sibling.