Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 30 additions & 1 deletion glyph/src/types.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
use anyhow::Result;
use anyhow::{anyhow, Result};
use serde::{Deserialize, Serialize};
use std::default::Default;
use std::str::FromStr;

#[derive(Serialize, Deserialize, Debug, Clone, PartialEq)]
Expand Down Expand Up @@ -104,3 +105,31 @@ pub struct WifiParams {
pub ssid: String,
pub password: String,
}

#[derive(Serialize, Deserialize, Debug, Clone, Copy, PartialEq)]
pub enum SignerType {
ReceiveOnly,
ReceiveSend,
}

impl SignerType {
pub fn to_byte(&self) -> u8 {
match self {
SignerType::ReceiveOnly => 0x5a,
SignerType::ReceiveSend => 0x8c,
}
}
pub fn from_byte(b: u8) -> Result<Self> {
match b {
0x5a => Ok(SignerType::ReceiveOnly),
0x8c => Ok(SignerType::ReceiveSend),
_ => Err(anyhow!("SignerType byte incorrect: {:x}", b)),
}
}
}

impl Default for SignerType {
fn default() -> Self {
SignerType::ReceiveSend
}
}