Skip to main content

AwsRestXmlProtocol

Struct AwsRestXmlProtocol 

Source
pub struct AwsRestXmlProtocol { /* private fields */ }
Expand description

AWS REST XML protocol (aws.protocols#restXml).

Implementations§

Source§

impl AwsRestXmlProtocol

Source

pub fn new() -> Self

Construct a new AwsRestXmlProtocol with default settings: Content-Type application/xml, date-time default timestamp format, error envelopes wrapped in <ErrorResponse> (i.e. noErrorWrapping = false), and no service-level @xmlNamespace.

Use Self::with_no_error_wrapping to opt in to the noErrorWrapping variant of the @restXml trait, and Self::with_service_xml_namespace to set a service-level default xmlns. Both methods are typically called by code generation based on the service shape’s traits; manual construction is fine for tests or custom protocols.

Source

pub fn with_no_error_wrapping(self, v: bool) -> Self

Configure whether error responses use the noErrorWrapping variant of the @restXml trait. When true, error response bodies have <Error> as the document root; when false (default), they are wrapped in <ErrorResponse><Error>...</Error>...</ErrorResponse>. Drives the parsing branch in parse_error_metadata and deserialize_error_response.

Unlike the service XML namespace, this has no config-bag default and cannot have one: it is read from @restXml(noErrorWrapping), and a model that does not use restXml carries no @restXml trait for a generated client to store. So when restXml is selected at runtime on, say, a CBOR-modeled service, there is nothing to recover — the caller must set it, and the documented default of false (wrapped envelopes, the spec default) applies otherwise.

This is the general limit of runtime protocol swapping: a protocol’s own trait data cannot be recovered from a model that does not use that protocol.

Source

pub fn no_error_wrapping(&self) -> bool

Returns the current noErrorWrapping setting. See Self::with_no_error_wrapping for semantics.

Source

pub fn with_service_xml_namespace( self, uri: impl Into<String>, prefix: Option<String>, ) -> Self

Configures the service-level @xmlNamespace declared on the Smithy service shape. Applied to request/response XML root elements that don’t carry their own @xmlNamespace (e.g. S3’s http://s3.amazonaws.com/doc/2006-03-01/).

Overrides the default, which is the ServiceXmlNamespace config-bag entry that generated clients store regardless of which protocol they were generated for. That default exists because a customer selecting restXml through Config::builder().protocol(..) has no way to know the model’s namespace.

Trait Implementations§

Source§

impl ClientProtocolInner for AwsRestXmlProtocol

Source§

fn parse_error_metadata( &self, response: &Response, _cfg: &ConfigBag, ) -> Result<ErrorMetadataBuilder, SerdeError>

Extracts canonical error metadata from a REST XML response.

Walks the error envelope structurally to extract Code / Message / Type from inside <Error> and (for the wrapped variant) RequestId from the outer <ErrorResponse>.

Honors Self::with_no_error_wrapping:

  • Wrapped (default): expects <ErrorResponse><Error><Code>...</Code>...</Error><RequestId>...</RequestId></ErrorResponse>.
  • Unwrapped (@restXml(noErrorWrapping: true)): expects <Error><Code>...</Code>...</Error> as the document root.

Per the ClientProtocolInner::parse_error_metadata contract the request id is not populated here — the orchestrator’s request-id pipeline attaches it separately. The RequestId element is captured into the builder’s extra slot under the key request_id for callers that need it.

Source§

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

Returns a ShapeDeserializer positioned inside <Error> so generated SpecificError::deserialize reads land on the right elements.

For the wrapped variant, uses find_error_element_slice to locate the <Error> sub-element. For noErrorWrapping, the body root IS <Error>, so the body is used unchanged.

The positioned deserializer is then wrapped so the error’s modeled @httpHeader, @httpPrefixHeaders, and @httpResponseCode members are read from the HTTP message. Envelope positioning and binding routing are independent: the codec sees the <Error> sub-slice, while the wrapper reads the response’s headers and status. This is why the wrapping helper takes an already-prepared body rather than building one.

Source§

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

This protocol labels structured event-stream payloads application/xml.

Must stay in agreement with the code generator’s eventStreamMessageContentType for this protocol (RestXml.kt:47), which supplies the fallback when a protocol declares no media type.

Source§

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

Parses the same restXml error envelope as ClientProtocolInner::parse_error_metadata, from an event-stream frame’s payload rather than an HTTP response body.

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 AwsRestXmlProtocol

Source§

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

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

impl Default for AwsRestXmlProtocol

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

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

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<<P as ClientProtocolInner>::Request, SerdeError>

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

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.
Source§

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

Extracts canonical error metadata from a response. Read more
Source§

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

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.
Source§

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

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

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

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

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.

Source§

impl<T> Instrument for T

Source§

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

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

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

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

Source§

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 = !

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

fn try_from(value: U) -> Result<T, !>

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.
Source§

impl<T> WithSubscriber for T

Source§

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

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

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