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§
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<Req, SerdeError>
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.
Sourcefn deserialize_response<'a>(
&self,
response: &'a Res,
output_schema: &Schema,
cfg: &ConfigBag,
) -> Result<Box<dyn ShapeDeserializer + 'a>, SerdeError>
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.
Sourcefn update_endpoint(
&self,
request: &mut Req,
endpoint: &Endpoint,
cfg: &ConfigBag,
) -> Result<(), SerdeError>
fn update_endpoint( &self, request: &mut Req, endpoint: &Endpoint, cfg: &ConfigBag, ) -> Result<(), SerdeError>
Updates a previously serialized request with a resolved endpoint.
Sourcefn payload_codec(&self) -> Option<&dyn DynCodec>
fn payload_codec(&self) -> Option<&dyn DynCodec>
Returns the codec used for payload (de)serialization, if any.