Add SpecialRoles with Demiurge
This commit is contained in:
parent
57182efbbc
commit
a69fa75822
26
src/lib.rs
26
src/lib.rs
@ -1,4 +1,5 @@
|
||||
use std::fmt::Debug;
|
||||
use std::str::FromStr;
|
||||
use std::sync::{Mutex, MutexGuard};
|
||||
|
||||
pub use aes_gcm;
|
||||
@ -22,6 +23,31 @@ pub mod silentpayments;
|
||||
|
||||
pub const MAX_PRD_PAYLOAD_SIZE: usize = u16::MAX as usize; // 64KiB sounds reasonable for now
|
||||
|
||||
#[derive(Debug, PartialEq, Eq)]
|
||||
pub enum SpecialRoles {
|
||||
DEMIURGE,
|
||||
}
|
||||
|
||||
impl std::fmt::Display for SpecialRoles {
|
||||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||
let role_str = match self {
|
||||
SpecialRoles::DEMIURGE => "demiurge",
|
||||
};
|
||||
write!(f, "{}", role_str)
|
||||
}
|
||||
}
|
||||
|
||||
impl FromStr for SpecialRoles {
|
||||
type Err = String;
|
||||
|
||||
fn from_str(s: &str) -> Result<Self, Self::Err> {
|
||||
match s {
|
||||
"demiurge" => Ok(SpecialRoles::DEMIURGE),
|
||||
_ => Err(format!("Invalid role: {}", s)),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub trait MutexExt<T> {
|
||||
fn lock_anyhow(&self) -> Result<MutexGuard<T>, anyhow::Error>;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user