pub struct CoseEnvelopeBuilder { /* private fields */ }Expand description
Configuration for a CoseEnvelope; see CoseEnvelope::server and
CoseEnvelope::client. Nothing is checked until build.
Implementations§
Source§impl CoseEnvelopeBuilder
impl CoseEnvelopeBuilder
Sourcepub fn skew(self, skew: Duration) -> CoseEnvelopeBuilder
pub fn skew(self, skew: Duration) -> CoseEnvelopeBuilder
How far iat may be from the opener’s clock, either way. Default
300 s. Sub-second parts are ignored.
It also sets how long a (kid, cti) stays in the nonce store:
2·skew + 1 seconds past iat (the second skew covers clock
disagreement between replicas and the store; see replay.rs), so
the store’s working set is every request of the last 2·skew + 1
seconds. build refuses a skew so large that this
expiry would leave the representable time range.
Sourcepub fn clock(
self,
clock: impl Fn() -> i64 + Send + Sync + 'static,
) -> CoseEnvelopeBuilder
pub fn clock( self, clock: impl Fn() -> i64 + Send + Sync + 'static, ) -> CoseEnvelopeBuilder
The clock iat is read from when sealing and checked against when
opening, in Unix seconds. Default: the system clock through
chrono (which, unlike SystemTime, works on
wasm32-unknown-unknown). Injectable so tests and the shared vectors
can pin iat. A reading before 1970 makes sealing a request fail
with a 500.
Sourcepub fn cti_source(
self,
cti: impl Fn() -> Result<Vec<u8>, CratestackError> + Send + Sync + 'static,
) -> CoseEnvelopeBuilder
pub fn cti_source( self, cti: impl Fn() -> Result<Vec<u8>, CratestackError> + Send + Sync + 'static, ) -> CoseEnvelopeBuilder
Where a request’s cti comes from. Default: 16 bytes from the
operating system’s CSPRNG (§5, nonce mode). Injectable so the
shared vectors can pin cti, in both the 16-byte and the 2-byte
counter shape. It must return 1 to 4 or 16 bytes; anything else, or
an Err, makes sealing fail with a 500.
Sourcepub fn nonce_source(
self,
nonce: impl Fn() -> Result<[u8; 16], CratestackError> + Send + Sync + 'static,
) -> CoseEnvelopeBuilder
pub fn nonce_source( self, nonce: impl Fn() -> Result<[u8; 16], CratestackError> + Send + Sync + 'static, ) -> CoseEnvelopeBuilder
Where CoseEnvelope::request_nonce gets its 16 bytes. Default:
the operating system’s CSPRNG. Injectable for tests and vectors.
Sourcepub fn nonce_store(self, store: Arc<dyn NonceStore>) -> CoseEnvelopeBuilder
pub fn nonce_store(self, store: Arc<dyn NonceStore>) -> CoseEnvelopeBuilder
A nonce store for a client envelope that also opens requests through
CoseEnvelope::open_request (a relay, or a test).
Sourcepub fn build(self) -> Result<CoseEnvelope, CratestackError>
pub fn build(self) -> Result<CoseEnvelope, CratestackError>
Check the configuration. Fails with CratestackError::Validation
when the signer’s algorithm belongs to the other mode, its kid is
not 8 bytes, or the skew is so large that a nonce’s expiry
(iat + 2·skew + 1, for any iat the opener could accept within the
next thousand years) would not be a representable time. Without that
last check such an envelope would build, and then answer every valid
request with a 401.
Trait Implementations§
Auto Trait Implementations§
impl !RefUnwindSafe for CoseEnvelopeBuilder
impl !UnwindSafe for CoseEnvelopeBuilder
impl Freeze for CoseEnvelopeBuilder
impl Send for CoseEnvelopeBuilder
impl Sync for CoseEnvelopeBuilder
impl Unpin for CoseEnvelopeBuilder
impl UnsafeUnpin for CoseEnvelopeBuilder
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
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> 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);