pub struct WebPushClient { /* private fields */ }Expand description
WebPush client.
Cheap to clone (all fields are Arc-backed).
Implementations§
Source§impl WebPushClient
impl WebPushClient
Sourcepub fn new(
vapid_pem: Option<&[u8]>,
admin_email: &str,
) -> Result<Self, WebPushError>
pub fn new( vapid_pem: Option<&[u8]>, admin_email: &str, ) -> Result<Self, WebPushError>
Construct from an existing PEM-encoded P-256 EC private key.
If vapid_pem is None, a fresh key is generated in memory.
Sourcepub fn new_with_persistence(
key_path: Option<&Path>,
admin_email: &str,
) -> Result<Self, WebPushError>
pub fn new_with_persistence( key_path: Option<&Path>, admin_email: &str, ) -> Result<Self, WebPushError>
Load or generate the VAPID key, optionally persisting it.
- If
key_pathisSomeand the file exists: loads the PEM. - If
key_pathisSomeand the file does NOT exist: generates a new key and writes it to the path so subsequent restarts use the same key. - If
key_pathisNone: generates an ephemeral in-memory key.
Sourcepub fn vapid_pubkey_base64url(&self) -> &str
pub fn vapid_pubkey_base64url(&self) -> &str
Return the base64url-encoded uncompressed VAPID public key.
This is the value that must be shared with push endpoints so they can
verify VAPID JWTs. Exposed for tests and for generating the VAPID public
key header in Crypto-Key.
Sourcepub async fn send(
&self,
subscription: &PushSubscription,
payload: &[u8],
) -> Result<(), WebPushError>
pub async fn send( &self, subscription: &PushSubscription, payload: &[u8], ) -> Result<(), WebPushError>
Send a WebPush message to subscription.
When subscription.keys is None (or RFC 8291 encryption is not yet
implemented) the body is left empty (tickle semantics). The VAPID JWT
is always included in the Authorization header per RFC 8444.
Trait Implementations§
Source§impl Clone for WebPushClient
impl Clone for WebPushClient
Source§fn clone(&self) -> WebPushClient
fn clone(&self) -> WebPushClient
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreAuto Trait Implementations§
impl Freeze for WebPushClient
impl !RefUnwindSafe for WebPushClient
impl Send for WebPushClient
impl Sync for WebPushClient
impl Unpin for WebPushClient
impl UnsafeUnpin for WebPushClient
impl !UnwindSafe for WebPushClient
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
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> FutureExt for T
impl<T> FutureExt for T
Source§fn with_context(self, otel_cx: Context) -> WithContext<Self>
fn with_context(self, otel_cx: Context) -> WithContext<Self>
Source§fn with_current_context(self) -> WithContext<Self>
fn with_current_context(self) -> WithContext<Self>
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§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>
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 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>
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 moreSource§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
Wrap the input message
T in a tonic::Request