jmap_client/push_subscription/
get.rs1use crate::{core::get::GetObject, Get, Set, DataType};
13
14use super::{Keys, PushSubscription};
15
16impl PushSubscription<Get> {
17 pub fn id(&self) -> Option<&str> {
18 self.id.as_deref()
19 }
20
21 pub fn take_id(&mut self) -> String {
22 self.id.take().unwrap_or_default()
23 }
24
25 pub fn device_client_id(&self) -> Option<&str> {
26 self.device_client_id.as_deref()
27 }
28
29 pub fn url(&self) -> Option<&str> {
30 self.url.as_deref()
31 }
32
33 pub fn keys(&self) -> Option<&Keys> {
34 self.keys.as_ref()
35 }
36
37 pub fn verification_code(&self) -> Option<&str> {
38 self.verification_code.as_deref()
39 }
40
41 pub fn expires(&self) -> Option<i64> {
42 self.expires.map(|v| v.timestamp())
43 }
44
45 pub fn types(&self) -> Option<&[DataType]> {
46 self.types.as_deref()
47 }
48}
49
50impl Keys {
51 pub fn p256dh(&self) -> Option<Vec<u8>> {
52 base64::decode_config(&self.p256dh, base64::URL_SAFE).ok()
53 }
54
55 pub fn auth(&self) -> Option<Vec<u8>> {
56 base64::decode_config(&self.auth, base64::URL_SAFE).ok()
57 }
58}
59
60impl GetObject for PushSubscription<Set> {
61 type GetArguments = ();
62}
63
64impl GetObject for PushSubscription<Get> {
65 type GetArguments = ();
66}