Skip to main content

miden_objects/decoded/
mod.rs

1//! Schema-shaped records with manually implemented domain construction.
2//!
3//! Explicitly choose the construction capability, either after decoding fields or through
4//! [`crate::DecodeMessageExt`]. For example, building a block header does not authenticate it
5//! against its parent:
6//!
7//! ```
8//! use miden_objects::{ConversionError, DecodeMessageExt, proto};
9//! use miden_protocol::block::BlockHeader;
10//!
11//! # fn build(message: proto::blockchain::BlockHeader)
12//! #     -> Result<BlockHeader, ConversionError> {
13//! let header = message.decode_and_build_unchecked()?;
14//! # Ok(header)
15//! # }
16//! ```
17//!
18//! Generated records deliberately do not provide direct protobuf-to-domain conversions, even
19//! when construction is checked or infallible. This keeps the trust decision explicit.
20//!
21//! ```compile_fail,E0277
22//! use miden_objects::proto;
23//! use miden_protocol::block::BlockHeader;
24//! let _: BlockHeader = proto::blockchain::BlockHeader::default().try_into().unwrap();
25//! ```
26//!
27//! Borrowing a message must not bypass that decision either:
28//!
29//! ```compile_fail,E0277
30//! use miden_objects::proto;
31//! use miden_protocol::block::BlockHeader;
32//! let message = proto::blockchain::BlockHeader::default();
33//! let _: BlockHeader = (&message).try_into().unwrap();
34//! ```
35//!
36//! ```compile_fail,E0277
37//! use miden_objects::proto;
38//! use miden_protocol::account::AccountId;
39//! let _: AccountId = proto::account::AccountId::default().try_into().unwrap();
40//! ```
41//!
42//! ```compile_fail,E0277
43//! use miden_objects::proto;
44//! use miden_protocol::block::BlockNumber;
45//! let _: BlockNumber = proto::blockchain::BlockNumber::default().into();
46//! ```
47//!
48//! A parsed MAST forest is not trusted until its structure and node hashes are verified:
49//!
50//! ```compile_fail,E0277
51//! use miden_objects::proto;
52//! use miden_protocol::MastForest;
53//! let _: MastForest = proto::primitives::MastForest::default().try_into().unwrap();
54//! ```
55//!
56//! ```compile_fail,E0277
57//! use miden_objects::proto;
58//! use miden_protocol::MastForest;
59//! let message = proto::primitives::MastForest::default();
60//! let _: MastForest = (&message).try_into().unwrap();
61//! ```
62
63mod error;
64pub use error::VerificationError;
65
66pub mod protocol_config;
67
68pub mod primitives;
69
70pub mod account;
71
72pub mod asset;
73
74pub mod transaction;
75
76pub mod blockchain;
77
78pub mod note;