ClientProtocol

Trait ClientProtocol 

Source
pub trait ClientProtocol<Req = Request, Res = Response>:
    Send
    + Sync
    + Debug {
    // Required methods
    fn protocol_id(&self) -> &ShapeId;
    fn serialize_request(
        &self,
        input: &dyn SerializableStruct,
        input_schema: &Schema,
        endpoint: &str,
        cfg: &ConfigBag,
    ) -> Result<Req, SerdeError>;
    fn deserialize_response<'a>(
        &self,
        response: &'a Res,
        output_schema: &Schema,
        cfg: &ConfigBag,
    ) -> Result<Box<dyn ShapeDeserializer + 'a>, SerdeError>;
    fn update_endpoint(
        &self,
        request: &mut Req,
        endpoint: &Endpoint,
        cfg: &ConfigBag,
    ) -> Result<(), SerdeError>;
    fn payload_codec(&self) -> Option<&dyn DynCodec>;
}
Expand description

Object-safe view of ClientProtocolInner parameterized over concrete request / response types.

This is what callers hold behind dyn — for example, SharedClientProtocol stores Arc<dyn ClientProtocol<Req, Res>> so the protocol can be swapped at runtime. The generic Req / Res parameters default to HTTP so existing call sites remain source-compatible.

Every ClientProtocolInner gets ClientProtocol for free via a blanket impl; implementors should write ClientProtocolInner only.

Required Methods§

Source

fn protocol_id(&self) -> &ShapeId

Returns the Smithy shape ID of this protocol.

Source

fn serialize_request( &self, input: &dyn SerializableStruct, input_schema: &Schema, endpoint: &str, cfg: &ConfigBag, ) -> Result<Req, SerdeError>

Serializes an operation input into a request message.

Source

fn deserialize_response<'a>( &self, response: &'a Res, output_schema: &Schema, cfg: &ConfigBag, ) -> Result<Box<dyn ShapeDeserializer + 'a>, SerdeError>

Deserializes a response message, returning a boxed ShapeDeserializer.

Source

fn update_endpoint( &self, request: &mut Req, endpoint: &Endpoint, cfg: &ConfigBag, ) -> Result<(), SerdeError>

Updates a previously serialized request with a resolved endpoint.

Source

fn payload_codec(&self) -> Option<&dyn DynCodec>

Returns the codec used for payload (de)serialization, if any.

Implementors§