pub struct AwsRestJsonProtocol { /* private fields */ }Expand description
AWS REST JSON 1.0 protocol (aws.protocols#restJson1).
This is a thin configuration wrapper that constructs an [HttpBindingProtocol]
with a JsonCodec using REST JSON settings. The HttpBindingProtocol handles
splitting members between HTTP bindings and the JSON payload.
Implementations§
Source§impl AwsRestJsonProtocol
impl AwsRestJsonProtocol
Sourcepub fn with_default_namespace(self, namespace: impl Into<String>) -> Self
pub fn with_default_namespace(self, namespace: impl Into<String>) -> Self
Configures the default Smithy namespace used to resolve relative
shape IDs in JSON __type discriminator fields. Forwarded to
JsonCodecSettings::default_namespace on the codec wrapped by
this protocol.
REST JSON services may emit relative __type values in document-
typed members; code-generated clients call this method with the
service shape’s namespace so the deserializer can produce a fully-
qualified discriminator.
Setting this explicitly overrides the default, which is the
ServiceShapeNamespace config-bag
entry that generated clients store regardless of which protocol they were generated for.
That fallback exists because a customer selecting restJson1 through
Config::builder().protocol(..) has no way to know the model’s namespace, and without it
every relative discriminator would stay unresolved. See
the internal codec_with_bag_namespace helper in protocol/mod.rs for how it is applied
and what it costs.
Trait Implementations§
Source§impl ClientProtocolInner for AwsRestJsonProtocol
impl ClientProtocolInner for AwsRestJsonProtocol
Source§fn deserialize_error_response<'a>(
&self,
response: &'a Response,
cfg: &'a ConfigBag,
) -> Result<Box<dyn ShapeDeserializer + 'a>, SerdeError>
fn deserialize_error_response<'a>( &self, response: &'a Response, cfg: &'a ConfigBag, ) -> Result<Box<dyn ShapeDeserializer + 'a>, SerdeError>
Returns a deserializer for a modeled error response.
restJson1 has no error envelope, so the body root already is the error body and there is
nothing to reposition. The override is therefore behavior-neutral today: the default
forwarding would route the error through
deserialize_response, and because the JSON codec reads an
empty body as an empty object, the success wrapper’s stricter empty-body handling is not
observable here. It is stated rather than relied upon.
It is overridden anyway so that error deserialization does not depend on two incidental
properties of the default forwarding: that prelude::DOCUMENT happens not to qualify for
the body-only fast path, and that this codec happens to accept an empty body. Neither is a
contract, and an error path that silently became the success path would drop every
transport-bound member. Being explicit also keeps every REST error path structurally
incapable of reaching the success fast path, which is the property the protocol-level
error tests assert.
The namespace fallback applies here too, so the branch structure matches
deserialize_response.
Source§fn parse_error_metadata(
&self,
response: &Response,
_cfg: &ConfigBag,
) -> Result<Builder, SerdeError>
fn parse_error_metadata( &self, response: &Response, _cfg: &ConfigBag, ) -> Result<Builder, SerdeError>
Extracts canonical error metadata from a restJson1 response.
restJson1 uses the same JSON error envelope as awsJson1.0 / 1.1:
__type (or legacy code) for the error code, with header
X-Amzn-Errortype taking priority; message / Message /
errorMessage for the message.
Per the
ClientProtocolInner::parse_error_metadata
contract the request id is not populated here — the
orchestrator’s request-id pipeline attaches it separately.
Source§fn event_stream_media_type(&self) -> Option<&str>
fn event_stream_media_type(&self) -> Option<&str>
This protocol labels structured event-stream payloads application/json.
Must stay in agreement with the code generator’s
eventStreamMessageContentType for this protocol (RestJson.kt:90), which supplies
the fallback when a protocol declares no media type.
Source§fn parse_event_stream_error_metadata(
&self,
payload: &[u8],
) -> Result<Builder, SerdeError>
fn parse_event_stream_error_metadata( &self, payload: &[u8], ) -> Result<Builder, SerdeError>
Parses the same JSON error envelope as
ClientProtocolInner::parse_error_metadata, from an event-stream
frame’s payload rather than an HTTP response body. An event-stream frame has
no HTTP headers, so the x-amzn-errortype route is unavailable here and an
empty header map is passed; the discriminator comes from the payload’s
__type.
Source§fn protocol_id(&self) -> &ShapeId<'static>
fn protocol_id(&self) -> &ShapeId<'static>
Source§fn serialize_request(
&self,
input: &dyn SerializableStruct,
input_schema: &Schema<'_>,
endpoint: &str,
cfg: &ConfigBag,
) -> Result<Request, SerdeError>
fn serialize_request( &self, input: &dyn SerializableStruct, input_schema: &Schema<'_>, endpoint: &str, cfg: &ConfigBag, ) -> Result<Request, SerdeError>
Source§fn deserialize_response<'a>(
&self,
response: &'a Response,
output_schema: &Schema<'_>,
cfg: &'a ConfigBag,
) -> Result<Box<dyn ShapeDeserializer + 'a>, SerdeError>
fn deserialize_response<'a>( &self, response: &'a Response, output_schema: &Schema<'_>, cfg: &'a ConfigBag, ) -> Result<Box<dyn ShapeDeserializer + 'a>, SerdeError>
ShapeDeserializer] that supplies
every member of output_schema this protocol carries in the response. Read moreSource§fn payload_codec(&self) -> Option<&dyn DynCodec>
fn payload_codec(&self) -> Option<&dyn DynCodec>
Source§impl Debug for AwsRestJsonProtocol
impl Debug for AwsRestJsonProtocol
Auto Trait Implementations§
impl Freeze for AwsRestJsonProtocol
impl RefUnwindSafe for AwsRestJsonProtocol
impl Send for AwsRestJsonProtocol
impl Sync for AwsRestJsonProtocol
impl Unpin for AwsRestJsonProtocol
impl UnsafeUnpin for AwsRestJsonProtocol
impl UnwindSafe for AwsRestJsonProtocol
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
§impl<P> ClientProtocol<<P as ClientProtocolInner>::Request, <P as ClientProtocolInner>::Response> for Pwhere
P: ClientProtocolInner,
impl<P> ClientProtocol<<P as ClientProtocolInner>::Request, <P as ClientProtocolInner>::Response> for Pwhere
P: ClientProtocolInner,
§fn protocol_id(&self) -> &ShapeId<'static>
fn protocol_id(&self) -> &ShapeId<'static>
§fn serialize_request(
&self,
input: &dyn SerializableStruct,
input_schema: &Schema<'_>,
endpoint: &str,
cfg: &ConfigBag,
) -> Result<<P as ClientProtocolInner>::Request, SerdeError>
fn serialize_request( &self, input: &dyn SerializableStruct, input_schema: &Schema<'_>, endpoint: &str, cfg: &ConfigBag, ) -> Result<<P as ClientProtocolInner>::Request, SerdeError>
§fn deserialize_response<'a>(
&self,
response: &'a <P as ClientProtocolInner>::Response,
output_schema: &Schema<'_>,
cfg: &'a ConfigBag,
) -> Result<Box<dyn ShapeDeserializer + 'a>, SerdeError>
fn deserialize_response<'a>( &self, response: &'a <P as ClientProtocolInner>::Response, output_schema: &Schema<'_>, cfg: &'a ConfigBag, ) -> Result<Box<dyn ShapeDeserializer + 'a>, SerdeError>
ShapeDeserializer].§fn parse_error_metadata(
&self,
response: &<P as ClientProtocolInner>::Response,
cfg: &ConfigBag,
) -> Result<Builder, SerdeError>
fn parse_error_metadata( &self, response: &<P as ClientProtocolInner>::Response, cfg: &ConfigBag, ) -> Result<Builder, SerdeError>
§fn deserialize_error_response<'a>(
&self,
response: &'a <P as ClientProtocolInner>::Response,
cfg: &'a ConfigBag,
) -> Result<Box<dyn ShapeDeserializer + 'a>, SerdeError>
fn deserialize_error_response<'a>( &self, response: &'a <P as ClientProtocolInner>::Response, cfg: &'a ConfigBag, ) -> Result<Box<dyn ShapeDeserializer + 'a>, SerdeError>
ShapeDeserializer] positioned at the body of an error
response — inside the protocol’s error envelope, where applicable. Read more§fn update_endpoint(
&self,
request: &mut <P as ClientProtocolInner>::Request,
endpoint: &Endpoint,
cfg: &ConfigBag,
) -> Result<(), SerdeError>
fn update_endpoint( &self, request: &mut <P as ClientProtocolInner>::Request, endpoint: &Endpoint, cfg: &ConfigBag, ) -> Result<(), SerdeError>
§fn payload_codec(&self) -> Option<&dyn DynCodec>
fn payload_codec(&self) -> Option<&dyn DynCodec>
§fn event_stream_media_type(&self) -> Option<&str>
fn event_stream_media_type(&self) -> Option<&str>
§fn parse_event_stream_error_metadata(
&self,
payload: &[u8],
) -> Result<Builder, SerdeError>
fn parse_event_stream_error_metadata( &self, payload: &[u8], ) -> Result<Builder, SerdeError>
exception frame’s
payload. Read more§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
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