gui_server_api/navigation/
lockscreen.rs

1// SPDX-FileCopyrightText: 2025 Foundation Devices, Inc. <hello@foundation.xyz>
2// SPDX-License-Identifier: GPL-3.0-or-later
3
4#[derive(Debug, rkyv::Serialize, rkyv::Deserialize, rkyv::Archive)]
5pub struct VerifyPinOptions {
6    pub title: Option<String>,
7    pub want_security_words: bool,
8}
9
10impl VerifyPinOptions {
11    pub fn from_slice(data: &[u8]) -> Option<Self> {
12        let Ok(archived) = rkyv::access::<ArchivedVerifyPinOptions, rkyv::rancor::Error>(data) else {
13            return None;
14        };
15        rkyv::deserialize::<Self, rkyv::rancor::Error>(archived).ok()
16    }
17
18    pub fn serialize(&self) -> Vec<u8> { rkyv::to_bytes::<rkyv::rancor::Error>(self).unwrap().to_vec() }
19}
20
21#[derive(Debug, rkyv::Serialize, rkyv::Deserialize, rkyv::Archive)]
22pub struct VerifyPinResult {
23    pub success: bool,
24    pub security_words: Option<[String; 2]>,
25}
26
27impl VerifyPinResult {
28    pub fn from_slice(data: &[u8]) -> Option<Self> {
29        let Ok(archived) = rkyv::access::<ArchivedVerifyPinResult, rkyv::rancor::Error>(data) else {
30            return None;
31        };
32        rkyv::deserialize::<Self, rkyv::rancor::Error>(archived).ok()
33    }
34
35    pub fn serialize(&self) -> Vec<u8> { rkyv::to_bytes::<rkyv::rancor::Error>(self).unwrap().to_vec() }
36}