Struct MaxFrameSize Copy item path Source pub struct MaxFrameSize();Expand description The largest frame a decoder will accept, in bytes, excluding the terminator.
A caller sets this. There is no constant a decoder falls back to, because a
ceiling nobody chose is a ceiling nobody has checked against the largest
message the application actually sends.
The inner type is NonZeroU32 : a limit of zero would accept no frame at
all, including the empty one, which is a configuration mistake rather than a
policy, and refusing it at construction is the last point at which the caller
can still see what they did.
§ Examples
use protocol_droid::domain::{MaxFrameSize, MaxFrameSizeError};
let limit = MaxFrameSize::new(8 * 1024 * 1024 )? ;
assert_eq! (limit.bytes(), 8 * 1024 * 1024 );
assert_eq! (MaxFrameSize::new(0 ), Err (MaxFrameSizeError::Zero));
assert! (MaxFrameSize::new(1 ).is_ok());A starting point, for a caller who wants one and will still name it.
Four mebibytes comfortably holds a tools/list of a large catalogue
while still bounding a hostile peer.
Builds a limit.
§ Errors
MaxFrameSizeError::Zero when bytes is zero. See the type’s docs for
why that is refused rather than accepted.
Performs copy-assignment from
source.
Read more Formats the value using the given formatter.
Read more Formats the value using the given formatter.
Read more Compares and returns the maximum of two values.
Read more Compares and returns the minimum of two values.
Read more Restrict a value to a certain interval.
Read more 🔬 This is a nightly-only experimental API. (clamp_to)
Restrict a value to a certain range.
Read more This method returns an ordering between
self and
other values if one exists.
Read more Tests less than (for
self and
other) and is used by the
< operator.
Read more Tests less than or equal to (for
self and
other) and is used by the
<= operator.
Read more Tests greater than (for
self and
other) and is used by the
>
operator.
Read more Tests greater than or equal to (for
self and
other) and is used by
the
>= operator.
Read more Immutably borrows from an owned value.
Read more Mutably borrows from an owned value.
Read more 🔬 This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from
self to
dest.
Read more Returns the argument unchanged.
Converts to this type from a reference to the input type.
Instruments this type with the provided
Span, returning an
Instrumented wrapper.
Read more Calls U::from(self).
That is, this conversion is whatever the implementation of
From <T> for U chooses to do.
The resulting type after obtaining ownership.
Creates owned data from borrowed data, usually by cloning.
Read more Uses borrowed data to replace owned data, usually by cloning.
Read more Converts the given value to a
String.
Read more The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.