pub struct AwsJsonRpcProtocol { /* private fields */ }Expand description
AWS JSON RPC protocol (awsJson1_0 / awsJson1_1).
Implementations§
Source§impl AwsJsonRpcProtocol
impl AwsJsonRpcProtocol
Sourcepub fn aws_json_1_0() -> Self
pub fn aws_json_1_0() -> Self
Creates an AWS JSON 1.0 protocol instance.
The X-Amz-Target prefix defaults to the Smithy service shape name from the config bag;
use Self::with_target_prefix to override it.
Sourcepub fn aws_json_1_1() -> Self
pub fn aws_json_1_1() -> Self
Creates an AWS JSON 1.1 protocol instance.
The X-Amz-Target prefix defaults to the Smithy service shape name from the config bag;
use Self::with_target_prefix to override it.
Sourcepub fn with_target_prefix(self, target_prefix: impl Into<String>) -> Self
pub fn with_target_prefix(self, target_prefix: impl Into<String>) -> Self
Overrides the prefix of the X-Amz-Target header.
By default the prefix is the Smithy service shape name, read from the
[ServiceShapeName] config-bag entry that generated clients store regardless of which
protocol they were generated for. That default exists because a customer selecting this
protocol through Config::builder().protocol(..) has no way to know the shape name, and an
incorrect X-Amz-Target is unroutable.
Override it when a service’s target prefix is not its shape name.
Note this is not the sdkId carried by
Metadata::service —
an sdkId may contain spaces ("JSON RPC 10") and is not a valid header value here.
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.
AWS JSON 1.0 / 1.1 services typically emit relative __type
values (the shape name without a namespace prefix). Code-generated
clients call this method with the service shape’s namespace so
that crate::codec::JsonDeserializer::read_discriminated_document
can produce a fully-qualified discriminator.
Unlike the X-Amz-Target prefix, this is a response-parsing concern rather than request
shaping — nothing on the serialization path reads it, because a serializer must always
emit an absolute shape ID.
Setting it explicitly overrides the default, which is the
ServiceShapeNamespace config-bag
entry that generated clients store regardless of which protocol they were generated for.
A caller selecting this protocol at runtime therefore gets relative __type resolution
without having to know the model’s namespace; previously it had to be set by hand or
discriminators stayed relative, which made the type registry silently miss the shape.
The fallback is applied per response because JsonCodec holds an Arc<JsonCodecSettings>
that create_deserializer clones by pointer, so there is nowhere to store the resolved
value on an immutable protocol. That costs ~46 ns per response and only when no explicit
namespace was configured. The internal codec_with_bag_namespace helper in
protocol/mod.rs carries the
measurement and the memoization option if it ever matters.
Trait Implementations§
Source§impl ClientProtocolInner for AwsJsonRpcProtocol
impl ClientProtocolInner for AwsJsonRpcProtocol
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>
Serializes an awsJson1_0 / awsJson1_1 request.
_endpoint is deliberately ignored: both protocols fix the request path at /, so the
route is a function of the protocol rather than of the operation, and a path computed by
codegen for a different protocol must not leak through when this protocol is selected at
runtime via Config::builder().protocol(..). apply_http_endpoint merges the scheme and
authority afterwards.
The assertion belongs here rather than in [HttpRpcProtocol] because only the concrete
protocol knows whether its route is constant — RpcV2CborProtocol legitimately passes
HttpRpcProtocol a computed /service/{service}/operation/{operation} route.
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 an awsJson1_0 / awsJson1_1
response.
awsJson protocols carry the error code in the __type (or legacy
code) field of the JSON body, with X-Amzn-Errortype taking
priority. The error message comes from message, Message, or
errorMessage body keys.
Per the
ClientProtocolInner::parse_error_metadata
contract the request id is not populated here — the
orchestrator’s request-id pipeline attaches it separately.
deserialize_error_response is not overridden: awsJson has no
error envelope, so the default (which forwards to
deserialize_response against
prelude::DOCUMENT) is
already correct — the body root IS the error body.
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 (AwsJson.kt:95), 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 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 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>
§fn deserialize_error_response<'a>(
&self,
response: &'a Self::Response,
cfg: &'a ConfigBag,
) -> Result<Box<dyn ShapeDeserializer + 'a>, SerdeError>
fn deserialize_error_response<'a>( &self, response: &'a Self::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 moreAuto Trait Implementations§
impl Freeze for AwsJsonRpcProtocol
impl RefUnwindSafe for AwsJsonRpcProtocol
impl Send for AwsJsonRpcProtocol
impl Sync for AwsJsonRpcProtocol
impl Unpin for AwsJsonRpcProtocol
impl UnsafeUnpin for AwsJsonRpcProtocol
impl UnwindSafe for AwsJsonRpcProtocol
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