use super::*;
#[derive(Debug, serde::Serialize, serde::Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct LairApiReqNewSeed {
pub msg_id: Arc<str>,
pub tag: Arc<str>,
#[serde(skip_serializing_if = "Option::is_none", default)]
pub deep_lock_passphrase: Option<DeepLockPassphrase>,
#[serde(skip_serializing_if = "is_false", default)]
pub exportable: bool,
}
impl LairApiReqNewSeed {
pub fn new(
tag: Arc<str>,
deep_lock_passphrase: Option<DeepLockPassphrase>,
exportable: bool,
) -> Self {
Self {
msg_id: new_msg_id(),
tag,
deep_lock_passphrase,
exportable,
}
}
}
impl std::convert::TryFrom<LairApiEnum> for LairApiReqNewSeed {
type Error = one_err::OneErr;
fn try_from(e: LairApiEnum) -> Result<Self, Self::Error> {
if let LairApiEnum::ReqNewSeed(s) = e {
Ok(s)
} else {
Err(format!("Invalid response type: {e:?}").into())
}
}
}
impl AsLairCodec for LairApiReqNewSeed {
fn into_api_enum(self) -> LairApiEnum {
LairApiEnum::ReqNewSeed(self)
}
}
#[derive(Debug, serde::Serialize, serde::Deserialize)]
#[serde(rename_all = "camelCase")]
#[non_exhaustive]
pub struct LairApiResNewSeed {
pub msg_id: Arc<str>,
pub tag: Arc<str>,
pub seed_info: SeedInfo,
}
impl std::convert::TryFrom<LairApiEnum> for LairApiResNewSeed {
type Error = one_err::OneErr;
fn try_from(e: LairApiEnum) -> Result<Self, Self::Error> {
if let LairApiEnum::ResNewSeed(s) = e {
Ok(s)
} else {
Err(format!("Invalid response type: {e:?}").into())
}
}
}
impl AsLairCodec for LairApiResNewSeed {
fn into_api_enum(self) -> LairApiEnum {
LairApiEnum::ResNewSeed(self)
}
}
impl AsLairRequest for LairApiReqNewSeed {
type Response = LairApiResNewSeed;
}
impl AsLairResponse for LairApiResNewSeed {
type Request = LairApiReqNewSeed;
}