pub struct WebPush { /* private fields */ }Expand description
Push over POST <subscription endpoint>.
Implementations§
Source§impl WebPush
impl WebPush
Sourcepub fn new(
http: Arc<dyn HttpClient>,
clock: Arc<dyn Clock>,
keys: VapidKeys,
) -> Result<Self, WebPushConfigError>
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.
Sourcepub fn with_record_size(
http: Arc<dyn HttpClient>,
clock: Arc<dyn Clock>,
keys: VapidKeys,
record_size: u32,
) -> Result<Self, WebPushConfigError>
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.
Sourcepub fn not_configured() -> Self
pub fn not_configured() -> Self
A degraded adapter that reports PushOutcome::NotConfigured
without any network call — for a venture with no VAPID key set.
Sourcepub fn public_key(&self) -> Option<&str>
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.
Sourcepub fn max_payload(&self) -> Option<usize>
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 Push for WebPush
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,
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,
notification to to.