INNER CODE UNIT · Rust
decode
risc0/risc0-ethereum · crates/aggregation/src/lib.rs:108
pub fn decode(bytes: impl AsRef<[u8]>) -> Result<Self, DecodingError> {
// Read the first 32 bytes as the self_image_id.
let (chunk, bytes) = bytes
.as_ref()
.split_at_checked(U256::BYTES)
.ok_or(DecodingError::UnexpectedEnd)?;
let self_image_id = Digest::try_from(chunk).unwrap();
let mmr = MerkleMountainRange::decode(bytes)?;
Ok(Self { self_image_id, mmr })
}
/// Create a [GuestInput] from this [GuestState]. When run with the guest, the given claims
/// will be accumulated into the Merkle mountain range, and will be finalized if `finalize` is
/// set to `true`.
///
/// Will return an error if the [MerkleMountainRange] on the [GuestState] is already
/// finalized, as no more claims may be added and the guest would reject this input.
pub fn into_input(