Skip to main content

AwsRestJsonProtocol

Struct AwsRestJsonProtocol 

Source
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

Source

pub fn new() -> Self

Creates a new REST JSON protocol with default settings.

Source

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.

Source

pub fn inner(&self) -> &HttpBindingProtocol<JsonCodec>

Returns a reference to the inner HttpBindingProtocol.

Trait Implementations§

Source§

impl ClientProtocolInner for AwsRestJsonProtocol

Source§

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>

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>

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>

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§

type Request = Request

The protocol’s request message type (e.g., http::Request).
Source§

type Response = Response

The protocol’s response message type (e.g., http::Response).
Source§

fn protocol_id(&self) -> &ShapeId<'static>

Returns the Smithy shape ID of this protocol.
Source§

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

Serializes an operation input into a request message. Read more
Source§

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

Deserializes a response message, returning a boxed [ShapeDeserializer] that supplies every member of output_schema this protocol carries in the response. Read more
Source§

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

Returns the codec used for payload (de)serialization, if any. Read more
Source§

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

Updates a previously serialized request with a resolved endpoint. Read more
Source§

impl Debug for AwsRestJsonProtocol

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for AwsRestJsonProtocol

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
§

impl<P> ClientProtocol<<P as ClientProtocolInner>::Request, <P as ClientProtocolInner>::Response> for P
where P: ClientProtocolInner,

§

fn protocol_id(&self) -> &ShapeId<'static>

Returns the Smithy shape ID of this protocol.
§

fn serialize_request( &self, input: &dyn SerializableStruct, input_schema: &Schema<'_>, endpoint: &str, cfg: &ConfigBag, ) -> Result<<P as ClientProtocolInner>::Request, SerdeError>

Serializes an operation input into a request message. Read more
§

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

Deserializes a response message, returning a boxed [ShapeDeserializer].
§

fn parse_error_metadata( &self, response: &<P as ClientProtocolInner>::Response, cfg: &ConfigBag, ) -> Result<Builder, SerdeError>

Extracts canonical error metadata from a response. Read more
§

fn deserialize_error_response<'a>( &self, response: &'a <P as ClientProtocolInner>::Response, cfg: &'a ConfigBag, ) -> Result<Box<dyn ShapeDeserializer + 'a>, SerdeError>

Returns a [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>

Updates a previously serialized request with a resolved endpoint.
§

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

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

fn event_stream_media_type(&self) -> Option<&str>

The media type used to label a structured event-stream payload, if any. Read more
§

fn parse_event_stream_error_metadata( &self, payload: &[u8], ) -> Result<Builder, SerdeError>

Extracts canonical error metadata from an event-stream exception frame’s payload. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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
§

impl<Unshared, Shared> IntoShared<Shared> for Unshared
where Shared: FromUnshared<Unshared>,

§

fn into_shared(self) -> Shared

Creates a shared type from an unshared type.
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more