pub struct FixedExtension<const N: usize> {
pub type: i8,
/* private fields */
}
Expand description
A fixed-capacity container for extension payloads of up to N
bytes.
This type name refers to the fixed-size backing buffer, not the MessagePack header kind. The actual header used at encode-time depends on the current payload length:
len == 1, 2, 4, 8, 16
→FixExtN
- otherwise (0..=255, 256..=65535, 65536..=u32::MAX) →
Ext8/16/32
Fields§
§type: i8
Application‑defined extension type code.
Implementations§
Source§impl<const N: usize> FixedExtension<N>
impl<const N: usize> FixedExtension<N>
Sourcepub fn new(type: i8, data: &[u8]) -> Option<Self>
pub fn new(type: i8, data: &[u8]) -> Option<Self>
Construct from a slice whose length must be <= N
.
The chosen MessagePack format when encoding still follows the rules described in the type-level documentation above.
Sourcepub fn new_fixed(type: i8, data: [u8; N]) -> Self
pub fn new_fixed(type: i8, data: [u8; N]) -> Self
Construct with an exact N
-byte payload.
Note: Even when constructed with a fixed-size buffer, the encoder will
emit FixExtN
only if N
is one of {1, 2, 4, 8, 16}. For any other
N
, the encoder uses Ext8/16/32
as appropriate.
Sourcepub fn as_ref(&self) -> ExtensionRef<'_>
pub fn as_ref(&self) -> ExtensionRef<'_>
Borrow as ExtensionRef
for encoding.
Trait Implementations§
Source§impl<const N: usize> Clone for FixedExtension<N>
impl<const N: usize> Clone for FixedExtension<N>
Source§fn clone(&self) -> FixedExtension<N>
fn clone(&self) -> FixedExtension<N>
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moreSource§impl<const N: usize> Debug for FixedExtension<N>
impl<const N: usize> Debug for FixedExtension<N>
Source§impl<'a, const N: usize> Decode<'a> for FixedExtension<N>
impl<'a, const N: usize> Decode<'a> for FixedExtension<N>
Source§impl<const N: usize> Ord for FixedExtension<N>
impl<const N: usize> Ord for FixedExtension<N>
Source§fn cmp(&self, other: &FixedExtension<N>) -> Ordering
fn cmp(&self, other: &FixedExtension<N>) -> Ordering
1.21.0 · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
Compares and returns the maximum of two values. Read more
Source§impl<const N: usize> PartialEq for FixedExtension<N>
impl<const N: usize> PartialEq for FixedExtension<N>
Source§impl<const N: usize> PartialOrd for FixedExtension<N>
impl<const N: usize> PartialOrd for FixedExtension<N>
impl<const N: usize> Eq for FixedExtension<N>
impl<const N: usize> StructuralPartialEq for FixedExtension<N>
Auto Trait Implementations§
impl<const N: usize> Freeze for FixedExtension<N>
impl<const N: usize> RefUnwindSafe for FixedExtension<N>
impl<const N: usize> Send for FixedExtension<N>
impl<const N: usize> Sync for FixedExtension<N>
impl<const N: usize> Unpin for FixedExtension<N>
impl<const N: usize> UnwindSafe for FixedExtension<N>
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