pub struct PushKey { /* private fields */ }Expand description
The kernel’s push key (spec 3.3 §5.4): a P-256 key, kept at <home>/push.key, that signs
the VAPID token of every push and that phones subscribe with. Its Debug shows only its
id.
Replicas share one key with adk-rust up --push-key <file>; each subscription remembers the
id of the key it was made with, and a replica sends only with that key.
§Example
use adk_surface::mobile::PushKey;
let home = tempfile::tempdir().unwrap();
let path = home.path().join(PushKey::FILE);
let key = PushKey::load_or_create(&path).unwrap();
assert_eq!(key.id(), PushKey::load_or_create(&path).unwrap().id());
assert_eq!(format!("{key:?}"), format!("PushKey({})", key.id()));Implementations§
Source§impl PushKey
impl PushKey
Sourcepub fn generate() -> Result<Self, MobileError>
pub fn generate() -> Result<Self, MobileError>
A new random key from the operating system’s generator.
§Errors
Returns MobileError::PushKey when the generator is unavailable.
Sourcepub fn from_bytes(bytes: [u8; 32]) -> Result<Self, MobileError>
pub fn from_bytes(bytes: [u8; 32]) -> Result<Self, MobileError>
The key with this secret scalar.
§Errors
Returns MobileError::PushKey when the bytes are not a P-256 secret key.
Sourcepub fn load_or_create(path: &Path) -> Result<Self, MobileError>
pub fn load_or_create(path: &Path) -> Result<Self, MobileError>
The key in the file at path, or a new one written there, readable only by its owner
on Unix (mode 0600). The file holds 64 hex digits. An empty file gets a new key and
keeps its permissions, so a caller can create it owner-only first.
§Errors
Returns MobileError::PushKey when the file cannot be read or created, or does not
hold a key.
Sourcepub fn id(&self) -> &str
pub fn id(&self) -> &str
The key’s id: what a subscription records, so a replica sends only with its key.
Sourcepub fn public_key(&self) -> &str
pub fn public_key(&self) -> &str
The public key a phone subscribes with (applicationServerKey): the uncompressed point,
base64url without padding.
Trait Implementations§
Auto Trait Implementations§
impl Forget for PushKey
impl Freeze for PushKey
impl Move for PushKey
impl RefUnwindSafe for PushKey
impl Send for PushKey
impl Sync for PushKey
impl Unpin for PushKey
impl UnsafeUnpin for PushKeywhere
Scalar: UnsafeUnpin,
AffinePoint<NistP256>: UnsafeUnpin,
*const u8 is !null: UnsafeUnpin,
PhantomData<u8>: UnsafeUnpin,
impl UnwindSafe for PushKey
Blanket Implementations§
Source§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
Source§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
Source§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
Source§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
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> ⓘ
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> ⓘ
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 more