use crate::*;
use std::sync::Arc;
pub mod traits {
use super::*;
pub trait AsLairCodec:
'static
+ std::fmt::Debug
+ serde::Serialize
+ for<'de> serde::Deserialize<'de>
+ std::convert::TryFrom<LairApiEnum>
{
fn into_api_enum(self) -> LairApiEnum;
}
pub trait AsLairRequest: AsLairCodec {
type Response: AsLairCodec;
}
pub trait AsLairResponse: AsLairCodec {
type Request: AsLairCodec;
}
}
use traits::*;
#[derive(Debug, serde::Serialize, serde::Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct DeepLockPassphrase {
pub ops_limit: u32,
pub mem_limit: u32,
pub passphrase: SecretDataSized<64, 81>,
}
fn new_msg_id() -> Arc<str> {
nanoid::nanoid!().into()
}
fn is_false(b: impl std::borrow::Borrow<bool>) -> bool {
!b.borrow()
}
mod error;
pub use error::*;
mod hello;
pub use hello::*;
mod unlock;
pub use unlock::*;
mod get_entry;
pub use get_entry::*;
mod list_entries;
pub use list_entries::*;
mod new_seed;
pub use new_seed::*;
mod export_seed_by_tag;
pub use export_seed_by_tag::*;
mod import_seed;
pub use import_seed::*;
mod sign_by_pub_key;
pub use sign_by_pub_key::*;
mod crypto_box_xsalsa_by_pub_key;
pub use crypto_box_xsalsa_by_pub_key::*;
mod crypto_box_xsalsa_open_by_pub_key;
pub use crypto_box_xsalsa_open_by_pub_key::*;
mod new_wka_tls_cert;
pub use new_wka_tls_cert::*;
mod get_wka_tls_cert_priv_key;
pub use get_wka_tls_cert_priv_key::*;
mod secret_box_xsalsa_by_tag;
pub use secret_box_xsalsa_by_tag::*;
mod secret_box_xsalsa_open_by_tag;
pub use secret_box_xsalsa_open_by_tag::*;
#[derive(Debug, serde::Serialize, serde::Deserialize)]
#[serde(tag = "type", rename_all = "camelCase")]
#[non_exhaustive]
pub enum LairApiEnum {
ResError(LairApiResError),
ReqHello(LairApiReqHello),
ResHello(LairApiResHello),
ReqUnlock(LairApiReqUnlock),
ResUnlock(LairApiResUnlock),
ReqGetEntry(LairApiReqGetEntry),
ResGetEntry(LairApiResGetEntry),
ReqListEntries(LairApiReqListEntries),
ResListEntries(LairApiResListEntries),
ReqNewSeed(LairApiReqNewSeed),
ResNewSeed(LairApiResNewSeed),
ReqExportSeedByTag(LairApiReqExportSeedByTag),
ResExportSeedByTag(LairApiResExportSeedByTag),
ReqImportSeed(LairApiReqImportSeed),
ResImportSeed(LairApiResImportSeed),
ReqSignByPubKey(LairApiReqSignByPubKey),
ResSignByPubKey(LairApiResSignByPubKey),
ReqCryptoBoxXSalsaByPubKey(LairApiReqCryptoBoxXSalsaByPubKey),
ResCryptoBoxXSalsaByPubKey(LairApiResCryptoBoxXSalsaByPubKey),
ReqCryptoBoxXSalsaOpenByPubKey(LairApiReqCryptoBoxXSalsaOpenByPubKey),
ResCryptoBoxXSalsaOpenByPubKey(LairApiResCryptoBoxXSalsaOpenByPubKey),
ReqNewWkaTlsCert(LairApiReqNewWkaTlsCert),
ResNewWkaTlsCert(LairApiResNewWkaTlsCert),
ReqGetWkaTlsCertPrivKey(LairApiReqGetWkaTlsCertPrivKey),
ResGetWkaTlsCertPrivKey(LairApiResGetWkaTlsCertPrivKey),
ReqSecretBoxXSalsaByTag(LairApiReqSecretBoxXSalsaByTag),
ResSecretBoxXSalsaByTag(LairApiResSecretBoxXSalsaByTag),
ReqSecretBoxXSalsaOpenByTag(LairApiReqSecretBoxXSalsaOpenByTag),
ResSecretBoxXSalsaOpenByTag(LairApiResSecretBoxXSalsaOpenByTag),
}
impl LairApiEnum {
pub fn msg_id(&self) -> Arc<str> {
match self {
Self::ResError(LairApiResError { msg_id, .. }) => msg_id.clone(),
Self::ReqHello(LairApiReqHello { msg_id, .. }) => msg_id.clone(),
Self::ResHello(LairApiResHello { msg_id, .. }) => msg_id.clone(),
Self::ReqUnlock(LairApiReqUnlock { msg_id, .. }) => msg_id.clone(),
Self::ResUnlock(LairApiResUnlock { msg_id, .. }) => msg_id.clone(),
Self::ReqGetEntry(LairApiReqGetEntry { msg_id, .. }) => {
msg_id.clone()
}
Self::ResGetEntry(LairApiResGetEntry { msg_id, .. }) => {
msg_id.clone()
}
Self::ReqListEntries(LairApiReqListEntries { msg_id, .. }) => {
msg_id.clone()
}
Self::ResListEntries(LairApiResListEntries { msg_id, .. }) => {
msg_id.clone()
}
Self::ReqNewSeed(LairApiReqNewSeed { msg_id, .. }) => {
msg_id.clone()
}
Self::ResNewSeed(LairApiResNewSeed { msg_id, .. }) => {
msg_id.clone()
}
Self::ReqExportSeedByTag(LairApiReqExportSeedByTag {
msg_id,
..
}) => msg_id.clone(),
Self::ResExportSeedByTag(LairApiResExportSeedByTag {
msg_id,
..
}) => msg_id.clone(),
Self::ReqImportSeed(LairApiReqImportSeed { msg_id, .. }) => {
msg_id.clone()
}
Self::ResImportSeed(LairApiResImportSeed { msg_id, .. }) => {
msg_id.clone()
}
Self::ReqSignByPubKey(LairApiReqSignByPubKey {
msg_id, ..
}) => msg_id.clone(),
Self::ResSignByPubKey(LairApiResSignByPubKey {
msg_id, ..
}) => msg_id.clone(),
Self::ReqCryptoBoxXSalsaByPubKey(
LairApiReqCryptoBoxXSalsaByPubKey { msg_id, .. },
) => msg_id.clone(),
Self::ResCryptoBoxXSalsaByPubKey(
LairApiResCryptoBoxXSalsaByPubKey { msg_id, .. },
) => msg_id.clone(),
Self::ReqCryptoBoxXSalsaOpenByPubKey(
LairApiReqCryptoBoxXSalsaOpenByPubKey { msg_id, .. },
) => msg_id.clone(),
Self::ResCryptoBoxXSalsaOpenByPubKey(
LairApiResCryptoBoxXSalsaOpenByPubKey { msg_id, .. },
) => msg_id.clone(),
Self::ReqNewWkaTlsCert(LairApiReqNewWkaTlsCert {
msg_id, ..
}) => msg_id.clone(),
Self::ResNewWkaTlsCert(LairApiResNewWkaTlsCert {
msg_id, ..
}) => msg_id.clone(),
Self::ReqGetWkaTlsCertPrivKey(LairApiReqGetWkaTlsCertPrivKey {
msg_id,
..
}) => msg_id.clone(),
Self::ResGetWkaTlsCertPrivKey(LairApiResGetWkaTlsCertPrivKey {
msg_id,
..
}) => msg_id.clone(),
Self::ReqSecretBoxXSalsaByTag(LairApiReqSecretBoxXSalsaByTag {
msg_id,
..
}) => msg_id.clone(),
Self::ResSecretBoxXSalsaByTag(LairApiResSecretBoxXSalsaByTag {
msg_id,
..
}) => msg_id.clone(),
Self::ReqSecretBoxXSalsaOpenByTag(
LairApiReqSecretBoxXSalsaOpenByTag { msg_id, .. },
) => msg_id.clone(),
Self::ResSecretBoxXSalsaOpenByTag(
LairApiResSecretBoxXSalsaOpenByTag { msg_id, .. },
) => msg_id.clone(),
}
}
}