pub struct PushHandler<'a> { /* private fields */ }Expand description
Handler for Web Push API endpoints.
Implementations§
Source§impl<'a> PushHandler<'a>
impl<'a> PushHandler<'a>
Sourcepub fn new(client: &'a MastodonClient) -> Self
pub fn new(client: &'a MastodonClient) -> Self
Creates a new PushHandler for the given client.
Sourcepub async fn get_subscription(&self) -> Result<WebPushSubscription>
pub async fn get_subscription(&self) -> Result<WebPushSubscription>
Fetches the current Web Push subscription.
Returns:
Result<WebPushSubscription>: The subscription.
Corresponds to GET /api/v1/push/subscription.
Sourcepub async fn subscribe(
&self,
endpoint: &str,
p256dh: &str,
auth: &str,
alerts: Option<WebPushAlerts>,
) -> Result<WebPushSubscription>
pub async fn subscribe( &self, endpoint: &str, p256dh: &str, auth: &str, alerts: Option<WebPushAlerts>, ) -> Result<WebPushSubscription>
Creates or updates a Web Push subscription.
Parameters:
endpoint: The endpoint of the Web Push subscription.p256dh: The p256dh public key.auth: The authentication secret.alerts: The alerts to enable.
Returns:
Result<WebPushSubscription>: The created/updated subscription.
Corresponds to POST /api/v1/push/subscription.
Sourcepub async fn update_alerts(
&self,
alerts: WebPushAlerts,
) -> Result<WebPushSubscription>
pub async fn update_alerts( &self, alerts: WebPushAlerts, ) -> Result<WebPushSubscription>
Updates existing Web Push alerts.
Parameters:
alerts: The updated alerts.
Returns:
Result<WebPushSubscription>: The updated subscription.
Corresponds to PUT /api/v1/push/subscription.
Sourcepub async fn unsubscribe(&self) -> Result<()>
pub async fn unsubscribe(&self) -> Result<()>
Deletes the current Web Push subscription.
Returns:
Result<()>: Success if the subscription was deleted.
Corresponds to DELETE /api/v1/push/subscription.
Auto Trait Implementations§
impl<'a> Freeze for PushHandler<'a>
impl<'a> !RefUnwindSafe for PushHandler<'a>
impl<'a> Send for PushHandler<'a>
impl<'a> Sync for PushHandler<'a>
impl<'a> Unpin for PushHandler<'a>
impl<'a> !UnwindSafe for PushHandler<'a>
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