Skip to main content

WebPush

Struct WebPush 

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

Push over POST <subscription endpoint>.

Implementations§

Source§

impl WebPush

Source

pub fn new( http: Arc<dyn HttpClient>, clock: Arc<dyn Clock>, keys: VapidKeys, ) -> Result<Self, WebPushConfigError>

Builds a live adapter, parsing the VAPID key up front so a malformed one is reported at construction rather than on the first send.

VapidKeys carries the VAPID_PRIVATE_KEY (a PKCS#8 PEM or the bare 32-byte P-256 scalar base64url) and the VAPID_SUBJECT contact URI. The public key is derived, never configured, so the pair cannot drift.

§Errors

WebPushConfigError::Vapid if the key or the subject is not usable.

Source

pub fn with_record_size( http: Arc<dyn HttpClient>, clock: Arc<dyn Clock>, keys: VapidKeys, record_size: u32, ) -> Result<Self, WebPushConfigError>

The same, with an explicit RFC 8188 record size.

The default is derived so the whole body fits the 4096 octets a push service is required to accept (ece::DEFAULT_RECORD_SIZE); raising it is a deliberate bet that a venture’s subscribers are all on services that accept more.

§Errors

WebPushConfigError::Vapid as WebPush::new; WebPushConfigError::Ece if the record size is below RFC 8188’s floor of 18.

Source

pub fn not_configured() -> Self

A degraded adapter that reports PushOutcome::NotConfigured without any network call — for a venture with no VAPID key set.

Source

pub fn public_key(&self) -> Option<&str>

The applicationServerKey a browser must pass to pushManager.subscribe(), base64url — or None when the adapter is not configured. A venture serves this to its client.

Source

pub fn max_payload(&self) -> Option<usize>

The largest JSON payload this adapter will send, in bytes — computed from the record size, see ece::max_plaintext.

Trait Implementations§

Source§

impl Debug for WebPush

Source§

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

Prints whether it is configured and the public half of the VAPID key — never the private key, which Es256Signer already refuses to print, and never a recipient.

Source§

impl Push for WebPush

Source§

fn send<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, to: &'life1 Recipient, notification: &'life2 Notification, ) -> Pin<Box<dyn Future<Output = Result<PushOutcome, PushError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait,

Sends notification to to.

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> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

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> 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, 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