INNER CODE UNIT · Rust
read_from_bytes
0xMiden/crypto · miden-serde-utils/src/lib.rs:448
fn read_from_bytes(bytes: &[u8]) -> Result<Self, DeserializationError> {
Self::read_from(&mut SliceReader::new(bytes))
}
/// Deserializes `Self` from bytes with a byte budget limit.
///
/// This is the recommended method for deserializing untrusted input. The budget limits
/// how many bytes can be consumed during deserialization, preventing denial-of-service
/// attacks that exploit length fields to cause huge allocations.
///
/// # Errors
/// Returns an error if:
/// * The budget is exhausted before deserialization completes.
/// * The `bytes` do not contain enough information to deserialize `Self`.
/// * The `bytes` do not represent a valid value for `Self`.
fn read_from_bytes_with_budget(
bytes: &[u8],
budget: usize,