pub trait PlatformDeserializableUntrusted {
// Required methods
fn deserialize_from_bytes_untrusted_with_bytes_len(
data: &[u8],
) -> Result<(Self, usize), ProtocolError>
where Self: Sized;
fn deserialize_from_bytes_untrusted_no_limit_with_bytes_len(
data: &[u8],
) -> Result<(Self, usize), ProtocolError>
where Self: Sized;
// Provided methods
fn deserialize_from_bytes_untrusted(
data: &[u8],
) -> Result<Self, ProtocolError>
where Self: Sized { ... }
fn deserialize_from_bytes_untrusted_no_limit(
data: &[u8],
) -> Result<Self, ProtocolError>
where Self: Sized { ... }
fn deserialize_from_bytes_untrusted_exact(
data: &[u8],
) -> Result<Self, ProtocolError>
where Self: Sized { ... }
}Expand description
Deserialization of bytes from outside this node: state transitions, query requests and cursors, proofs, SDK responses, host-supplied input.
Runs bincode’s untrusted decoder, which reserves nothing from a length prefix before the elements it announces have actually been read, so a short input claiming a huge collection fails instead of allocating.
The derive implements the two _with_bytes_len methods, which report how
many bytes the value took; the other methods are defaults over them.
Required Methods§
Sourcefn deserialize_from_bytes_untrusted_with_bytes_len(
data: &[u8],
) -> Result<(Self, usize), ProtocolError>where
Self: Sized,
fn deserialize_from_bytes_untrusted_with_bytes_len(
data: &[u8],
) -> Result<(Self, usize), ProtocolError>where
Self: Sized,
Decodes under the type’s configured byte budget, returning the value and the number of bytes it took.
Sourcefn deserialize_from_bytes_untrusted_no_limit_with_bytes_len(
data: &[u8],
) -> Result<(Self, usize), ProtocolError>where
Self: Sized,
fn deserialize_from_bytes_untrusted_no_limit_with_bytes_len(
data: &[u8],
) -> Result<(Self, usize), ProtocolError>where
Self: Sized,
Self::deserialize_from_bytes_untrusted_with_bytes_len without the
byte budget.
Provided Methods§
Sourcefn deserialize_from_bytes_untrusted(data: &[u8]) -> Result<Self, ProtocolError>where
Self: Sized,
fn deserialize_from_bytes_untrusted(data: &[u8]) -> Result<Self, ProtocolError>where
Self: Sized,
Decodes under the type’s configured byte budget. Bytes left over after
the value are ignored; Self::deserialize_from_bytes_untrusted_exact
refuses them.
fn deserialize_from_bytes_untrusted_no_limit(
data: &[u8],
) -> Result<Self, ProtocolError>where
Self: Sized,
Sourcefn deserialize_from_bytes_untrusted_exact(
data: &[u8],
) -> Result<Self, ProtocolError>where
Self: Sized,
fn deserialize_from_bytes_untrusted_exact(
data: &[u8],
) -> Result<Self, ProtocolError>where
Self: Sized,
Self::deserialize_from_bytes_untrusted that also refuses bytes left
over after the value.
A value followed by anything decodes loosely as the value alone, so a caller that shows a user what the bytes contain and then signs them must use this one to know the value is all there is.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".