Struct NoEnvelope
pub struct NoEnvelope;Expand description
Pass-through envelope used when transport-layer signing is not required.
It is zero-cost. seal and open return the Bytes they were given,
the same allocation, through a std::future::Ready, so the unsigned
path neither copies nor allocates (tests/no_envelope_alloc.rs asserts
this with a counting allocator). open records no signer, because an
unsigned body proves nothing about who sent it. Adopting the async trait
therefore changes nothing for an existing service.
media_type is None for every shape. The previous implementation
answered "application/octet-stream", which was wrong for a CBOR body.
Nothing called it, so nothing noticed.
Trait Implementations§
§impl Clone for NoEnvelope
impl Clone for NoEnvelope
§fn clone(&self) -> NoEnvelope
fn clone(&self) -> NoEnvelope
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more§impl CratestackEnvelope for NoEnvelope
impl CratestackEnvelope for NoEnvelope
§fn media_type(&self, _shape: BodyShape) -> Option<&'static str>
fn media_type(&self, _shape: BodyShape) -> Option<&'static str>
Content-Type of a sealed body of this shape. None means this
envelope adds no framing for shape, so the body keeps the
payload’s own media type (the codec’s CONTENT_TYPE, or
application/cbor-seq) and content negotiation is unchanged. Read more§fn seal<'a>(
&'a self,
payload: Bytes,
_bind: &'a Binding<'a>,
) -> impl Future<Output = Result<Bytes, CratestackError>> + Send + 'a
fn seal<'a>( &'a self, payload: Bytes, _bind: &'a Binding<'a>, ) -> impl Future<Output = Result<Bytes, CratestackError>> + Send + 'a
payload, the codec’s output byte for byte, for the peer that
will rebuild bind. It runs after codec.encode.§fn open<'a>(
&'a self,
body: Bytes,
_bind: &'a Binding<'a>,
_ctx: &'a mut CratestackContext,
) -> impl Future<Output = Result<Bytes, CratestackError>> + Send + 'a
fn open<'a>( &'a self, body: Bytes, _bind: &'a Binding<'a>, _ctx: &'a mut CratestackContext, ) -> impl Future<Output = Result<Bytes, CratestackError>> + Send + 'a
body against bind, run the replay checks, and return the
payload for codec.decode. The result should be a zero-copy slice of
body, because the verifier checks exactly the bytes it received and
nothing is re-serialized (§1). Read more§fn stream_sealer(
&self,
_bind: Binding<'static>,
) -> Option<Box<dyn StreamSealer>>
fn stream_sealer( &self, _bind: Binding<'static>, ) -> Option<Box<dyn StreamSealer>>
None when this envelope does
not sign streams (plain cbor-seq passes through). It takes
Binding<'static> because the sealer outlives the request borrow:
chain mode’s h₀ = SHA-256(external_aad) needs the binding (§6).§fn stream_opener(
&self,
_bind: Binding<'static>,
) -> Option<Box<dyn StreamOpener>>
fn stream_opener( &self, _bind: Binding<'static>, ) -> Option<Box<dyn StreamOpener>>
None when this envelope does
not verify streams. See stream_sealer.§fn seal_value<'a, C, T>(
&'a self,
codec: &'a C,
value: &'a T,
bind: &'a Binding<'a>,
) -> impl Future<Output = Result<Bytes, CratestackError>> + Send + 'a
fn seal_value<'a, C, T>( &'a self, codec: &'a C, value: &'a T, bind: &'a Binding<'a>, ) -> impl Future<Output = Result<Bytes, CratestackError>> + Send + 'a
§impl Debug for NoEnvelope
impl Debug for NoEnvelope
§impl Default for NoEnvelope
impl Default for NoEnvelope
§fn default() -> NoEnvelope
fn default() -> NoEnvelope
Auto Trait Implementations§
impl Freeze for NoEnvelope
impl RefUnwindSafe for NoEnvelope
impl Send for NoEnvelope
impl Sync for NoEnvelope
impl Unpin for NoEnvelope
impl UnsafeUnpin for NoEnvelope
impl UnwindSafe for NoEnvelope
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<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].