pub struct AwsRestXmlProtocol { /* private fields */ }Expand description
AWS REST XML protocol (aws.protocols#restXml).
Implementations§
Source§impl AwsRestXmlProtocol
impl AwsRestXmlProtocol
Sourcepub fn new() -> Self
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.
Sourcepub fn with_no_error_wrapping(self, v: bool) -> Self
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.
Sourcepub fn no_error_wrapping(&self) -> bool
pub fn no_error_wrapping(&self) -> bool
Returns the current noErrorWrapping setting. See
Self::with_no_error_wrapping for semantics.
Sourcepub fn with_service_xml_namespace(
self,
uri: impl Into<String>,
prefix: Option<String>,
) -> Self
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
impl ClientProtocolInner for AwsRestXmlProtocol
Source§fn parse_error_metadata(
&self,
response: &Response,
_cfg: &ConfigBag,
) -> Result<ErrorMetadataBuilder, SerdeError>
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>
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>
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>
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§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§fn update_endpoint(
&self,
request: &mut Request,
endpoint: &Endpoint,
cfg: &ConfigBag,
) -> Result<(), SerdeError>
fn update_endpoint( &self, request: &mut Request, endpoint: &Endpoint, cfg: &ConfigBag, ) -> Result<(), SerdeError>
Source§impl Debug for AwsRestXmlProtocol
impl Debug for AwsRestXmlProtocol
Auto Trait Implementations§
impl Freeze for AwsRestXmlProtocol
impl RefUnwindSafe for AwsRestXmlProtocol
impl Send for AwsRestXmlProtocol
impl Sync for AwsRestXmlProtocol
impl Unpin for AwsRestXmlProtocol
impl UnsafeUnpin for AwsRestXmlProtocol
impl UnwindSafe for AwsRestXmlProtocol
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
Source§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,
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<<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>
Source§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.Source§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>
Source§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 moreSource§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>
Source§fn payload_codec(&self) -> Option<&dyn DynCodec>
fn payload_codec(&self) -> Option<&dyn DynCodec>
Source§fn event_stream_media_type(&self) -> Option<&str>
fn event_stream_media_type(&self) -> Option<&str>
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>
exception frame’s
payload. Read moreSource§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§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