pub struct ResolvedRoute { /* private fields */ }Expand description
A resolved op: the binding’s route and path_params.
Implementations§
Source§impl ResolvedRoute
impl ResolvedRoute
Sourcepub fn new(
route: impl Into<Cow<'static, str>>,
path_params: Vec<String>,
) -> ResolvedRoute
pub fn new( route: impl Into<Cow<'static, str>>, path_params: Vec<String>, ) -> ResolvedRoute
route as the client binds it: the RPC op id (batch for
/rpc/batch, subscribe/<op id> for a subscription), or the REST
route template as the schema declares it, without the mount prefix.
path_params in the order they are bound.
Sourcepub fn with_contract_key(
self,
key: impl Into<Cow<'static, str>>,
) -> ResolvedRoute
pub fn with_contract_key( self, key: impl Into<Cow<'static, str>>, ) -> ResolvedRoute
The op whose contract digest this route is bound under, when the
route a custom resolver binds (a versioned /v1/... path, say) is
not itself the op’s key: the RPC op_id, or "<METHOD> <template>"
on REST, as the generated ACCEPTED_CONTRACTS spells it. Without
it the layer looks the route up as given (the op id, or the method
and template), and a route with no row is a 500 for a signed
request: the layer cannot tell which shape the request was
signed under.
Sourcepub fn contract_key(&self) -> Option<&str>
pub fn contract_key(&self) -> Option<&str>
The key set by with_contract_key.
Sourcepub fn path_params(&self) -> &[String]
pub fn path_params(&self) -> &[String]
The path parameter values.
Sourcepub fn op(&self) -> &str
pub fn op(&self) -> &str
The op an super::EnvelopePolicy is asked about: the route, or for
a subscription the bare op id after subscribe/ (decision B1).
Sourcepub fn is_subscription(&self) -> bool
pub fn is_subscription(&self) -> bool
Bound as subscribe/<op id>: an RPC subscription, which streams and
so can never answer a signed request (the layer refuses it with a
sealed 406 before the handler runs).
Source§impl ResolvedRoute
impl ResolvedRoute
Sourcepub fn with_payload_types(
self,
request: &'static [&'static str],
response: &'static [&'static str],
) -> ResolvedRoute
pub fn with_payload_types( self, request: &'static [&'static str], response: &'static [&'static str], ) -> ResolvedRoute
The payload types this route accepts and answers in, narrowing what
the layer allows (EnvelopeLayerBuilder::payload_media_types) for
this route alone: an op’s allowed set is the layer’s set intersected
with this one. The built-in resolvers fill it from the schema’s
capabilities.request_types / response_types; a custom resolver
that sets none does not narrow.
use cratestack_axum::envelope_layer::ResolvedRoute;
let route = ResolvedRoute::new("/v1/charges", vec![]).with_payload_types(
&["application/x-www-form-urlencoded"],
&["application/json"],
);
assert_eq!(
route.payload_request_types(),
Some(&["application/x-www-form-urlencoded"][..])
);
assert_eq!(route.payload_response_types(), Some(&["application/json"][..]));
assert_eq!(ResolvedRoute::new("/v1/charges", vec![]).payload_request_types(), None);Sourcepub fn payload_request_types(&self) -> Option<&'static [&'static str]>
pub fn payload_request_types(&self) -> Option<&'static [&'static str]>
The request types set by with_payload_types.
Sourcepub fn payload_response_types(&self) -> Option<&'static [&'static str]>
pub fn payload_response_types(&self) -> Option<&'static [&'static str]>
The response types set by with_payload_types.
Trait Implementations§
Source§impl Clone for ResolvedRoute
impl Clone for ResolvedRoute
Source§fn clone(&self) -> ResolvedRoute
fn clone(&self) -> ResolvedRoute
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for ResolvedRoute
impl Debug for ResolvedRoute
impl Eq for ResolvedRoute
Source§impl PartialEq for ResolvedRoute
impl PartialEq for ResolvedRoute
Source§fn eq(&self, other: &ResolvedRoute) -> bool
fn eq(&self, other: &ResolvedRoute) -> bool
self and other values to be equal, and is used by ==.impl StructuralPartialEq for ResolvedRoute
Auto Trait Implementations§
impl Freeze for ResolvedRoute
impl RefUnwindSafe for ResolvedRoute
impl Send for ResolvedRoute
impl Sync for ResolvedRoute
impl Unpin for ResolvedRoute
impl UnsafeUnpin for ResolvedRoute
impl UnwindSafe for ResolvedRoute
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<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.impl<A, B, T> HttpServerConnExec<A, B> for Twhere
B: Body,
§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§impl<'src, T> IntoMaybe<'src, T> for Twhere
T: 'src,
impl<'src, T> IntoMaybe<'src, T> for Twhere
T: 'src,
impl<T> MaybeSend for T
impl<T> MaybeSendSync for T
impl<T> OrderedSeq<'_, T> for Twhere
T: Clone,
§impl<T> Paint for Twhere
T: ?Sized,
impl<T> Paint for Twhere
T: ?Sized,
§fn fg(&self, value: Color) -> Painted<&T>
fn fg(&self, value: Color) -> Painted<&T>
Returns a styled value derived from self with the foreground set to
value.
This method should be used rarely. Instead, prefer to use color-specific
builder methods like red() and
green(), which have the same functionality but are
pithier.
§Example
Set foreground color to white using fg():
use yansi::{Paint, Color};
painted.fg(Color::White);Set foreground color to white using white().
use yansi::Paint;
painted.white();§fn bright_black(&self) -> Painted<&T>
fn bright_black(&self) -> Painted<&T>
§fn bright_red(&self) -> Painted<&T>
fn bright_red(&self) -> Painted<&T>
§fn bright_green(&self) -> Painted<&T>
fn bright_green(&self) -> Painted<&T>
§fn bright_yellow(&self) -> Painted<&T>
fn bright_yellow(&self) -> Painted<&T>
§fn bright_blue(&self) -> Painted<&T>
fn bright_blue(&self) -> Painted<&T>
§fn bright_magenta(&self) -> Painted<&T>
fn bright_magenta(&self) -> Painted<&T>
§fn bright_cyan(&self) -> Painted<&T>
fn bright_cyan(&self) -> Painted<&T>
§fn bright_white(&self) -> Painted<&T>
fn bright_white(&self) -> Painted<&T>
§fn bg(&self, value: Color) -> Painted<&T>
fn bg(&self, value: Color) -> Painted<&T>
Returns a styled value derived from self with the background set to
value.
This method should be used rarely. Instead, prefer to use color-specific
builder methods like on_red() and
on_green(), which have the same functionality but
are pithier.
§Example
Set background color to red using fg():
use yansi::{Paint, Color};
painted.bg(Color::Red);Set background color to red using on_red().
use yansi::Paint;
painted.on_red();§fn on_primary(&self) -> Painted<&T>
fn on_primary(&self) -> Painted<&T>
§fn on_magenta(&self) -> Painted<&T>
fn on_magenta(&self) -> Painted<&T>
§fn on_bright_black(&self) -> Painted<&T>
fn on_bright_black(&self) -> Painted<&T>
§fn on_bright_red(&self) -> Painted<&T>
fn on_bright_red(&self) -> Painted<&T>
§fn on_bright_green(&self) -> Painted<&T>
fn on_bright_green(&self) -> Painted<&T>
§fn on_bright_yellow(&self) -> Painted<&T>
fn on_bright_yellow(&self) -> Painted<&T>
§fn on_bright_blue(&self) -> Painted<&T>
fn on_bright_blue(&self) -> Painted<&T>
§fn on_bright_magenta(&self) -> Painted<&T>
fn on_bright_magenta(&self) -> Painted<&T>
§fn on_bright_cyan(&self) -> Painted<&T>
fn on_bright_cyan(&self) -> Painted<&T>
§fn on_bright_white(&self) -> Painted<&T>
fn on_bright_white(&self) -> Painted<&T>
§fn attr(&self, value: Attribute) -> Painted<&T>
fn attr(&self, value: Attribute) -> Painted<&T>
Enables the styling [Attribute] value.
This method should be used rarely. Instead, prefer to use
attribute-specific builder methods like bold() and
underline(), which have the same functionality
but are pithier.
§Example
Make text bold using attr():
use yansi::{Paint, Attribute};
painted.attr(Attribute::Bold);Make text bold using using bold().
use yansi::Paint;
painted.bold();§fn rapid_blink(&self) -> Painted<&T>
fn rapid_blink(&self) -> Painted<&T>
§fn quirk(&self, value: Quirk) -> Painted<&T>
fn quirk(&self, value: Quirk) -> Painted<&T>
Enables the yansi [Quirk] value.
This method should be used rarely. Instead, prefer to use quirk-specific
builder methods like mask() and
wrap(), which have the same functionality but are
pithier.
§Example
Enable wrapping using .quirk():
use yansi::{Paint, Quirk};
painted.quirk(Quirk::Wrap);Enable wrapping using wrap().
use yansi::Paint;
painted.wrap();§fn clear(&self) -> Painted<&T>
👎Deprecated since 1.0.1: renamed to resetting() due to conflicts with Vec::clear().
The clear() method will be removed in a future release.
fn clear(&self) -> Painted<&T>
renamed to resetting() due to conflicts with Vec::clear().
The clear() method will be removed in a future release.
§fn whenever(&self, value: Condition) -> Painted<&T>
fn whenever(&self, value: Condition) -> Painted<&T>
Conditionally enable styling based on whether the [Condition] value
applies. Replaces any previous condition.
See the crate level docs for more details.
§Example
Enable styling painted only when both stdout and stderr are TTYs:
use yansi::{Paint, Condition};
painted.red().on_yellow().whenever(Condition::STDOUTERR_ARE_TTY);§impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> Read<Exclusive, BecauseExclusive> for Twhere
T: ?Sized,
§impl<'p, T> Seq<'p, T> for Twhere
T: Clone,
impl<'p, T> Seq<'p, T> for Twhere
T: Clone,
§type Iter<'a> = Once<&'a T>
where
T: 'a
type Iter<'a> = Once<&'a T> where T: 'a
§fn contains(&self, val: &T) -> boolwhere
T: PartialEq,
fn contains(&self, val: &T) -> boolwhere
T: PartialEq,
§fn to_maybe_ref<'b>(item: <T as Seq<'p, T>>::Item<'b>) -> Maybe<T, &'p T>where
'p: 'b,
fn to_maybe_ref<'b>(item: <T as Seq<'p, T>>::Item<'b>) -> Maybe<T, &'p T>where
'p: 'b,
MaybeRef].