diff --git a/src/lib.rs b/src/lib.rs index f1b0d88..82316b7 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1,6 +1,10 @@ +use std::sync::{Mutex, MutexGuard}; +use std::fmt::Debug; + pub use sp_client; pub use uuid; pub use log; +pub use aes_gcm; pub mod crypto; pub mod device; @@ -11,3 +15,16 @@ pub mod prd; pub mod process; pub mod silentpayments; pub mod signature; + +pub const MAX_PRD_PAYLOAD_SIZE: usize = u16::MAX as usize; // 64KiB sounds reasonable for now + +pub trait MutexExt { + fn lock_anyhow(&self) -> Result, anyhow::Error>; +} + +impl MutexExt for Mutex { + fn lock_anyhow(&self) -> Result, anyhow::Error> { + self.lock() + .map_err(|e| anyhow::Error::msg(format!("Failed to lock: {}", e))) + } +}