use crate::alloc::string::ToString;
use core::fmt::{Debug, Formatter};
use minicbor::{CborLen, Decode, Encode};
use ockam_core::compat::vec::Vec;
use ockam_core::{cbor_encode_preallocate, Decodable, Encodable, Encoded, Message};
pub const IDENTIFIER_LEN: usize = 32;
pub const CHANGE_HASH_LEN: usize = 32;
#[derive(Clone, Hash, Ord, PartialOrd, Eq, PartialEq, Encode, Decode, CborLen)]
#[cbor(transparent)]
pub struct Identifier(#[cbor(n(0), with = "minicbor::bytes")] pub [u8; IDENTIFIER_LEN]);
impl Debug for Identifier {
fn fmt(&self, f: &mut Formatter<'_>) -> core::fmt::Result {
f.write_str(&self.to_string())
}
}
#[derive(Clone, Eq, PartialEq, Encode, Decode, CborLen, Message)]
#[cbor(transparent)]
pub struct IdentifierList(#[n(0)] pub Vec<Identifier>);
impl Encodable for IdentifierList {
fn encode(self) -> ockam_core::Result<Encoded> {
cbor_encode_preallocate(self)
}
}
impl Decodable for IdentifierList {
fn decode(e: &[u8]) -> ockam_core::Result<Self> {
Ok(minicbor::decode(e)?)
}
}
#[derive(Clone, Debug, Eq, PartialEq, Encode, Decode, CborLen)]
#[cbor(transparent)]
pub struct ChangeHash(#[cbor(n(0), with = "minicbor::bytes")] pub [u8; CHANGE_HASH_LEN]);