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_with_prefix(
type: i8,
len: usize,
data: [u8; N],
) -> Result<Self, ExtensionCapacityError>
pub fn new_fixed_with_prefix( type: i8, len: usize, data: [u8; N], ) -> Result<Self, ExtensionCapacityError>
Construct with a logical prefix
Sourcepub fn as_ref(&self) -> ExtensionRef<'_>
pub fn as_ref(&self) -> ExtensionRef<'_>
Borrow as ExtensionRef
for encoding.
Sourcepub fn as_mut_slice(&mut self) -> &mut [u8] ⓘ
pub fn as_mut_slice(&mut self) -> &mut [u8] ⓘ
Extract a mutable slice
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<'de, const N: usize> DecodeBorrowed<'de> for FixedExtension<N>
impl<'de, const N: usize> DecodeBorrowed<'de> for FixedExtension<N>
Source§type Value = FixedExtension<N>
type Value = FixedExtension<N>
The decoded value.
Source§fn decode_borrowed_with_format<R>(
format: Format,
reader: &mut R,
) -> Result<Self::Value, DecodeError<R::Error>>where
R: IoRead<'de>,
fn decode_borrowed_with_format<R>(
format: Format,
reader: &mut R,
) -> Result<Self::Value, DecodeError<R::Error>>where
R: IoRead<'de>,
Decode with a previously read
Format
.Source§fn decode_borrowed<R>(
reader: &mut R,
) -> Result<<Self as DecodeBorrowed<'de>>::Value, Error<R::Error>>where
R: IoRead<'de>,
fn decode_borrowed<R>(
reader: &mut R,
) -> Result<<Self as DecodeBorrowed<'de>>::Value, Error<R::Error>>where
R: IoRead<'de>,
Decode the next value.
Source§impl<const N: usize> From<FixedExtension<N>> for ExtensionOwned
Available on crate feature alloc
only.
impl<const N: usize> From<FixedExtension<N>> for ExtensionOwned
Available on crate feature
alloc
only.Source§fn from(value: FixedExtension<N>) -> Self
fn from(value: FixedExtension<N>) -> Self
Converts to this type from the input type.
Source§impl From<Timestamp32> for FixedExtension<4>
impl From<Timestamp32> for FixedExtension<4>
Source§fn from(value: Timestamp32) -> Self
fn from(value: Timestamp32) -> Self
Converts to this type from the input type.
Source§impl From<Timestamp64> for FixedExtension<8>
impl From<Timestamp64> for FixedExtension<8>
Source§fn from(value: Timestamp64) -> Self
fn from(value: Timestamp64) -> Self
Converts to this type from the input type.
Source§impl From<Timestamp96> for FixedExtension<12>
impl From<Timestamp96> for FixedExtension<12>
Source§fn from(value: Timestamp96) -> Self
fn from(value: Timestamp96) -> Self
Converts to this type from the input type.
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>
Source§impl<const N: usize> TryFrom<ExtensionRef<'_>> for FixedExtension<N>
impl<const N: usize> TryFrom<ExtensionRef<'_>> for FixedExtension<N>
Source§type Error = ExtensionCapacityError
type Error = ExtensionCapacityError
The type returned in the event of a conversion error.
Source§impl TryFrom<FixedExtension<12>> for Timestamp96
impl TryFrom<FixedExtension<12>> for Timestamp96
Source§type Error = TryFromTimestampError
type Error = TryFromTimestampError
The type returned in the event of a conversion error.
Source§impl TryFrom<FixedExtension<4>> for Timestamp32
impl TryFrom<FixedExtension<4>> for Timestamp32
Source§type Error = TryFromTimestampError
type Error = TryFromTimestampError
The type returned in the event of a conversion error.
Source§impl TryFrom<FixedExtension<8>> for Timestamp64
impl TryFrom<FixedExtension<8>> for Timestamp64
Source§type Error = TryFromTimestampError
type Error = TryFromTimestampError
The type returned in the event of a conversion error.
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<'de, T> Decode<'de> for Twhere
T: DecodeBorrowed<'de> + 'de,
impl<'de, T> Decode<'de> for Twhere
T: DecodeBorrowed<'de> + 'de,
Source§type Value<'a> = <T as DecodeBorrowed<'de>>::Value
where
'de: 'a,
T: 'a
type Value<'a> = <T as DecodeBorrowed<'de>>::Value where 'de: 'a, T: 'a
The decoded value (may borrow for
'a
).