1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
impl_id!(
pub MilestoneId,
32,
"A milestone identifier, the BLAKE2b-256 hash of the milestone bytes. See <https://www.blake2.net/> for more information."
);
#[cfg(feature = "serde")]
string_serde_impl!(MilestoneId);
#[cfg(feature = "inx")]
mod inx {
use super::*;
impl From<MilestoneId> for ::inx::proto::MilestoneId {
fn from(value: MilestoneId) -> Self {
Self { id: value.0.to_vec() }
}
}
impl TryFrom<::inx::proto::MilestoneId> for MilestoneId {
type Error = crate::block::error::inx::InxError;
fn try_from(value: ::inx::proto::MilestoneId) -> Result<Self, Self::Error> {
let bytes: [u8; MilestoneId::LENGTH] = value
.id
.try_into()
.map_err(|e| Self::Error::InvalidId("MilestoneId", e))?;
Ok(MilestoneId::from(bytes))
}
}
}