pub trait TailCodec: Sized {
const MAX_ENCODED_LEN: usize;
// Required methods
fn encode(&self, out: &mut [u8]) -> Result<usize, ProgramError>;
fn decode(input: &[u8]) -> Result<(Self, usize), ProgramError>;
}Expand description
Canonical serializer for dynamic-tail payloads.
Implementations encode into a caller-provided buffer and decode
from a caller-provided slice, returning the byte count consumed
in both directions. Byte counts drive the length-prefix handling
inside #[hopper::state]’s generated tail accessors. the
encoding must be deterministic and bidirectional.
Required Associated Constants§
Sourceconst MAX_ENCODED_LEN: usize
const MAX_ENCODED_LEN: usize
Upper bound on the encoded size. Used by generated helpers to
verify the account has enough room before invoking encode.
Implementors should pick the smallest valid bound. Hopper
uses this to pre-size reallocs.
Required Methods§
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.