Skip to main content

Destination

Struct Destination 

Source
pub struct Destination {
    pub name: String,
    pub url: String,
    pub authentication: Option<PushAuthentication>,
    pub signing: Option<BodySigning>,
}
Expand description

One place the deployment sends its own events.

Fields§

§name: String

What the operator calls it. Appears in logs and in the stored id.

§url: String

Where to POST. Not checked against an allowlist, because there is no caller to check — see the module docs.

§authentication: Option<PushAuthentication>

HTTP authentication for the receiver, if it wants any.

§signing: Option<BodySigning>

A body signature for the receiver, if it verifies one.

None means deliveries carry no signature at all — not an unsigned header, no header. See signed_with for what a signature is and is not evidence of.

Implementations§

Source§

impl Destination

Source

pub fn new(name: impl Into<String>, url: impl Into<String>) -> Self

Source

pub fn authenticated( self, scheme: impl Into<String>, credentials: Secret, ) -> Self

Source

pub fn signed_with(self, secret: &Secret) -> Self

Sign every delivery to this destination under secret.

Standard Webhooks: webhook-signature: v1,<base64> over {webhook-id}.{webhook-timestamp}.{body}. It is beside authenticated, not instead of it: a bearer header proves the sender held a token, which is a claim about the connection and not about the bytes, and that token transits every hop between here and the receiver.

What the receiver must still do itself — refuse a stale webhook-timestamp and deduplicate on webhook-id, without which a captured POST replays — is set out on BodySigning, and a receiver is being written against those limits whether or not anybody read them.

§Panics

If the key is shorter than 24 bytes, or a whsec_-prefixed secret is not base64. Both are this deployment’s own configuration, so both are refused where they are written rather than at the far end of a run.

Use try_signed_with where the secret is read from configuration inside a builder — a panic there takes the process down from underneath the code that was assembling it.

Source

pub fn try_signed_with(self, secret: &Secret) -> Result<Self, SigningKeyError>

signed_with, reporting a bad key rather than aborting.

RuntimeBuilder::build and try_build in the small. A deployment reads this secret inside its own build(), so a mistyped one belongs in that builder’s error path — with the exit code and the log line naming which destination was wrong, none of which a panic reaches.

§Errors

SigningKeyError — a whsec_ secret that is not base64, or a key under the 24 bytes Standard Webhooks requires.

Source

pub fn also_signed_with(self, secret: &Secret) -> Self

Sign every delivery under this secret as well — the mid-rotation form. The receiver holding either key verifies, so the old secret can be retired at the receiver’s pace instead of on a flag day.

§Panics

As signed_with; and if no primary secret was configured first, because “also” without a first key is a wiring mistake worth naming at configuration.

Source

pub fn try_also_signed_with( self, secret: &Secret, ) -> Result<Self, SigningKeyError>

also_signed_with, reporting rather than aborting — try_signed_with’s argument, with the same force: both secrets come from the same file, at the same moment, inside the same builder.

§Errors

SigningKeyError — a bad key, or NoPrimary when no primary secret is configured.

Source

pub fn registration_id(&self) -> String

The stored registration id for this destination.

Trait Implementations§

Source§

impl Clone for Destination

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Debug for Destination

Source§

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

Formats the value using the given formatter. Read more

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
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<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

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

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> DynClone for T
where T: Clone,

Source§

fn __clone_box(&self, _: Private) -> *mut ()

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> FromRef<T> for T
where T: Clone,

Source§

fn from_ref(input: &T) -> T

Converts to this type from a reference to the input type.
Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

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
Source§

impl<Unshared, Shared> IntoShared<Shared> for Unshared
where Shared: FromUnshared<Unshared>,

Source§

fn into_shared(self) -> Shared

Creates a shared type from an unshared type.
Source§

impl<T> MaybeSend for T
where T: Send,

Source§

impl<T> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

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

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
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 = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

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.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

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
Source§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more