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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
//! Schema-shaped records with manually implemented domain construction.
//!
//! Decode fields first, then explicitly choose the construction capability. For example, building
//! a block header does not authenticate it against its parent:
//!
//! ```
//! use miden_objects::{BuildUnchecked, DecodeMessage, proto};
//! use miden_protocol::block::BlockHeader;
//!
//! # fn build(message: proto::blockchain::BlockHeader)
//! # -> Result<BlockHeader, Box<dyn core::error::Error + Send + Sync>> {
//! let decoded = message.decode_fields()?;
//! let header = decoded.build_unchecked()?;
//! # Ok(header)
//! # }
//! ```
//!
//! Generated records deliberately do not provide direct protobuf-to-domain conversions, even
//! when construction is checked or infallible. This keeps the trust decision explicit.
//!
//! ```compile_fail,E0277
//! use miden_objects::proto;
//! use miden_protocol::block::BlockHeader;
//! let _: BlockHeader = proto::blockchain::BlockHeader::default().try_into().unwrap();
//! ```
//!
//! Borrowing a message must not bypass that decision either:
//!
//! ```compile_fail,E0277
//! use miden_objects::proto;
//! use miden_protocol::block::BlockHeader;
//! let message = proto::blockchain::BlockHeader::default();
//! let _: BlockHeader = (&message).try_into().unwrap();
//! ```
//!
//! ```compile_fail,E0277
//! use miden_objects::proto;
//! use miden_protocol::account::AccountId;
//! let _: AccountId = proto::account::AccountId::default().try_into().unwrap();
//! ```
//!
//! ```compile_fail,E0277
//! use miden_objects::proto;
//! use miden_protocol::block::BlockNumber;
//! let _: BlockNumber = proto::blockchain::BlockNumber::default().into();
//! ```
//!
//! A parsed MAST forest is not trusted until its structure and node hashes are verified:
//!
//! ```compile_fail,E0277
//! use miden_objects::proto;
//! use miden_protocol::MastForest;
//! let _: MastForest = proto::primitives::MastForest::default().try_into().unwrap();
//! ```
//!
//! ```compile_fail,E0277
//! use miden_objects::proto;
//! use miden_protocol::MastForest;
//! let message = proto::primitives::MastForest::default();
//! let _: MastForest = (&message).try_into().unwrap();
//! ```
pub use VerificationError;