Struct web_push::WebPushMessageBuilder
source · [−]pub struct WebPushMessageBuilder<'a> { /* private fields */ }
Expand description
The main class for creating a notification payload.
Implementations
sourceimpl<'a> WebPushMessageBuilder<'a>
impl<'a> WebPushMessageBuilder<'a>
sourcepub fn new(
subscription_info: &'a SubscriptionInfo
) -> Result<WebPushMessageBuilder<'a>, WebPushError>
pub fn new(
subscription_info: &'a SubscriptionInfo
) -> Result<WebPushMessageBuilder<'a>, WebPushError>
Creates a builder for generating the web push payload.
All parameters are from the subscription info given by browser when subscribing to push notifications.
sourcepub fn set_ttl(&mut self, ttl: u32)
pub fn set_ttl(&mut self, ttl: u32)
How long the server should keep the message if it cannot be delivered currently. If not set, the message is deleted immediately on failed delivery.
sourcepub fn set_vapid_signature(&mut self, vapid_signature: VapidSignature)
pub fn set_vapid_signature(&mut self, vapid_signature: VapidSignature)
Add a VAPID signature to the request. To be generated with the VapidSignatureBuilder.
sourcepub fn set_payload(&mut self, encoding: ContentEncoding, content: &'a [u8])
pub fn set_payload(&mut self, encoding: ContentEncoding, content: &'a [u8])
If set, the client will get content in the notification. Has a maximum size of 3800 characters.
Currently, Aes128Gcm is the recommended and only encoding standard implemented.
sourcepub fn build(self) -> Result<WebPushMessage, WebPushError>
pub fn build(self) -> Result<WebPushMessage, WebPushError>
Builds and if set, encrypts the payload. Any errors due to bad encryption will be
WebPushError::Unspecified
, meaning
something was wrong in the given public key or authentication.
You can further debug these issues by checking the API responses visible with
log::trace
level.
Auto Trait Implementations
impl<'a> RefUnwindSafe for WebPushMessageBuilder<'a>
impl<'a> Send for WebPushMessageBuilder<'a>
impl<'a> Sync for WebPushMessageBuilder<'a>
impl<'a> Unpin for WebPushMessageBuilder<'a>
impl<'a> UnwindSafe for WebPushMessageBuilder<'a>
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<T> Instrument for T
impl<T> Instrument for T
sourcefn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Instruments this type with the provided Span
, returning an
Instrumented
wrapper. Read more
sourcefn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
sourceimpl<T> Instrument for T
impl<T> Instrument for T
sourcefn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Instruments this type with the provided Span
, returning an
Instrumented
wrapper. Read more
sourcefn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
impl<T> Same<T> for T
impl<T> Same<T> for T
type Output = T
type Output = T
Should always be Self
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
fn vzip(self) -> V
sourceimpl<T> WithSubscriber for T
impl<T> WithSubscriber for T
sourcefn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> where
S: Into<Dispatch>,
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
sourcefn with_current_subscriber(self) -> WithDispatch<Self>
fn with_current_subscriber(self) -> WithDispatch<Self>
Attaches the current default Subscriber
to this type, returning a
WithDispatch
wrapper. Read more