pub trait EncodePayload<T: ?Sized>: PayloadCodec {
// Required methods
fn payload_layout(value: &T) -> Result<PayloadLayout, UWireError>;
fn encode_payload(value: &T, dst: &mut [u8]) -> Result<(), UWireError>;
// Provided method
fn encode_payload_owned(value: &T) -> Result<Bytes, UWireError> { ... }
}Expand description
Encodes a typed value with a PayloadCodec.
Required Methods§
Sourcefn payload_layout(value: &T) -> Result<PayloadLayout, UWireError>
fn payload_layout(value: &T) -> Result<PayloadLayout, UWireError>
Returns the exact payload layout required to encode value.
This is a measurement operation, not necessarily a constant-time size
lookup. A variable-length codec may serialize or traverse value here
and perform the work again in Self::encode_payload. Benchmarks and
callers that care about this cost should label the probe and write phases
separately. The returned length and alignment are the complete contract
for the destination passed to encode_payload.
§Errors
Returns an error if the value cannot be measured for this codec.
Sourcefn encode_payload(value: &T, dst: &mut [u8]) -> Result<(), UWireError>
fn encode_payload(value: &T, dst: &mut [u8]) -> Result<(), UWireError>
Provided Methods§
Sourcefn encode_payload_owned(value: &T) -> Result<Bytes, UWireError>
fn encode_payload_owned(value: &T) -> Result<Bytes, UWireError>
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.