Skip to main content

ProtocolRegistry

Struct ProtocolRegistry 

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

A const collection of ProtocolRegistrations.

Each protocol may be registered exactly once across every registry a service consults; a duplicate fails the build. Order within a registry carries no meaning.

MultiProtocolRoutingService always includes Self::BUILTIN. Claim priority comes only from ProtocolOrder constraints, resolved transitively over all registrations, including protocols the service does not serve. Reordering registries or the service’s protocol declarations does not change priority. Constraints must order every pair of served protocols; unordered pairs and cycles fail the build.

Implementations§

Source§

impl ProtocolRegistry

Source

pub const BUILTIN: ProtocolRegistry

The built-in protocols, constrained to the following claim order (first to last):

  1. smithy.protocols#rpcv2Cbor
  2. aws.protocols#awsJson1_0
  3. aws.protocols#awsJson1_1
  4. aws.protocols#restJson1
  5. aws.protocols#restXml

This follows Smithy’s AWS service protocol precision order for the supported protocols. See also server protocol selection for protocol identification and claiming.

Only protocols declared by the service participate in request routing. Their relative order remains the same when the service declares a subset of the built-ins. Additional registrations can position custom protocols using ProtocolOrder, but there is no per-service override of the built-in relative order. Registering a built-in again fails the build.

This order affects wire behavior when requests match multiple protocols: the first definite claim wins; if none exists, the first deferred claim wins, followed by the first deferred rejection. See the routing documentation. For example, an eligible request without Content-Type receives deferred claims from both restJson1 and restXml; restJson1 wins if no protocol claims definitively.

Adding a built-in protocol or changing ordering constraints can change the selected protocol and its response format for ambiguous requests. Such changes require a wire compatibility review.

Source

pub const fn new(registrations: &'static [ProtocolRegistration]) -> Self

Creates a registry over registrations.

Source

pub fn resolve_id( &self, service_schema: &'static ServiceSchema<'static>, protocol_id: &str, ) -> Result<Option<SharedServerProtocol>, RouterBuildError>

Builds the protocol with shape ID protocol_id for service_schema, without settings.

Returns Ok(None) when this registry does not register protocol_id or the schema does not declare it. Factory failures and registered-ID mismatches return Err. Use Self::resolve_id_with_settings to supply a protocol’s configuration.

Source

pub fn resolve_id_with_settings( &self, service_schema: &'static ServiceSchema<'static>, protocol_id: &str, settings: Option<&Document>, ) -> Result<Option<SharedServerProtocol>, RouterBuildError>

Builds one declared protocol with its own settings document.

Generated response tests pass the protocol’s section from customizationConfig.protocols so serialization uses the same options as the generated service builder. Availability checks and factory errors behave as in Self::resolve_id.

Trait Implementations§

Source§

impl Clone for ProtocolRegistry

Source§

fn clone(&self) -> ProtocolRegistry

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for ProtocolRegistry

Source§

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

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

impl Copy for ProtocolRegistry

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
§

impl<T> AsOut<T> for T
where T: Copy,

§

fn as_out(&mut self) -> Out<'_, T>

Returns an out reference to self.
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<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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
§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,