Skip to main content

checked_encode_size

Function checked_encode_size 

Source
pub fn checked_encode_size(size: u32) -> Result<u32, EncodeError>
Expand description

Validate a computed encode size against MAX_MESSAGE_BYTES.

The error-returning half of the encode-size funnel: the try_encode* methods (and generated inherent encode entry points, e.g. on lazy view types) validate their compute_size result through this before writing anything.

ยงErrors

Returns EncodeError::MessageTooLarge if size exceeds MAX_MESSAGE_BYTES.