#[non_exhaustive]pub enum LengthWidth {
U8,
U16,
U32,
U24,
U64,
}Expand description
Width of the length prefix, in bytes.
Marked #[non_exhaustive] so wider prefix widths can be added in future
minor releases without a major version bump.
Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
Non-exhaustive enums could have additional variants added in future. Therefore, when matching against variants of non-exhaustive enums, an extra wildcard arm must be added to account for any future variants.
U8
One-byte length prefix; payload up to 255 bytes.
U16
Two-byte length prefix; payload up to 65 535 bytes.
U32
Four-byte length prefix; payload up to 4 294 967 295 bytes.
U24
Three-byte length prefix; payload up to 16 777 215 bytes.
Used by HTTP/2 frame headers, TLS handshake messages, and MySQL packets.
U64
Eight-byte length prefix; payload up to u64::MAX bytes.
On targets where usize is narrower than 64 bits, a length that does
not fit in usize is reported as Error::FrameTooLarge.
Implementations§
Source§impl LengthWidth
impl LengthWidth
Sourcepub const fn header_size(self) -> usize
pub const fn header_size(self) -> usize
Width of the prefix in bytes.
§Example
use wire_codec::framing::LengthWidth;
assert_eq!(LengthWidth::U24.header_size(), 3);Sourcepub const fn max_payload(self) -> u64
pub const fn max_payload(self) -> u64
Largest value the prefix can encode.
§Example
use wire_codec::framing::LengthWidth;
assert_eq!(LengthWidth::U16.max_payload(), 65_535);Trait Implementations§
Source§impl Clone for LengthWidth
impl Clone for LengthWidth
impl Copy for LengthWidth
Source§impl Debug for LengthWidth
impl Debug for LengthWidth
impl Eq for LengthWidth
Source§impl Hash for LengthWidth
impl Hash for LengthWidth
Source§impl PartialEq for LengthWidth
impl PartialEq for LengthWidth
impl StructuralPartialEq for LengthWidth
Auto Trait Implementations§
impl Forget for LengthWidth
impl Freeze for LengthWidth
impl Move for LengthWidth
impl RefUnwindSafe for LengthWidth
impl Send for LengthWidth
impl Sync for LengthWidth
impl Unpin for LengthWidth
impl UnsafeUnpin for LengthWidth
impl UnwindSafe for LengthWidth
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more