Skip to main content

miden_objects/decoded/primitives/
mast.rs

1use crate::{Verify, proto};
2
3#[cfg(test)]
4mod tests;
5
6/// A parsed MAST payload whose structure and node hashes have not yet been verified.
7#[derive(Debug)]
8pub struct UntrustedMastForest(miden_protocol::assembly::mast::UntrustedMastForest);
9
10impl TryFrom<alloc::vec::Vec<u8>> for UntrustedMastForest {
11    type Error = miden_protocol::utils::serde::DeserializationError;
12
13    fn try_from(bytes: alloc::vec::Vec<u8>) -> Result<Self, Self::Error> {
14        miden_protocol::assembly::mast::UntrustedMastForest::read_from_bytes(&bytes).map(Self)
15    }
16}
17
18pub use proto::primitives::DecodedMastForest as MastForest;
19
20impl Verify for MastForest {
21    type Verified = miden_protocol::MastForest;
22    type Error = miden_protocol::assembly::mast::MastForestError;
23
24    fn verify(self) -> Result<Self::Verified, Self::Error> {
25        self.encoded.0.validate()
26    }
27}