pub struct Ext {
pub kind: i8,
pub data: Vec<u8>,
}Expand description
A MessagePack extension value: a type and binary data.
Extensions whose type the format does not understand are passed through
deser as extension atoms of this type. Their fallback is the binary
data, so an extension deserializes into Vec<u8> if the type is not of
interest. Values of this type are written as extensions.
use deser_msgpack::Ext;
let bytes = deser_msgpack::to_vec(&Ext::new(7, vec![1, 2, 3])).unwrap();
assert_eq!(bytes, [0xc7, 0x03, 0x07, 0x01, 0x02, 0x03]);
let value: Ext = deser_msgpack::from_slice(&bytes).unwrap();
assert_eq!(value, Ext::new(7, vec![1, 2, 3]));Timestamps (type -1) are converted to and from
Timestamp instead. They are still
accepted by this type which then holds their encoding.
Fields§
§kind: i8The type of the extension (-128 to -1 are reserved by the
specification).
data: Vec<u8>The data of the extension.
Implementations§
Trait Implementations§
Source§impl<'de> Deserialize<'de> for Ext
impl<'de> Deserialize<'de> for Ext
Source§fn deserialize_atom(
slot: &mut Slot<Self>,
atom: Atom<'_>,
state: &mut State,
) -> Result<(), Error>
fn deserialize_atom( slot: &mut Slot<Self>, atom: Atom<'_>, state: &mut State, ) -> Result<(), Error>
Deserializes an atom into the slot. Read more
Source§fn expecting() -> Cow<'static, str>
fn expecting() -> Cow<'static, str>
Returns what the value expects, for error messages. Read more
Source§fn deserialize_into<'out>(
out: &'out mut Option<T>,
state: &mut State,
) -> SinkHandle<'out, 'de>
fn deserialize_into<'out>( out: &'out mut Option<T>, state: &mut State, ) -> SinkHandle<'out, 'de>
Creates a sink that deserializes the value into the given slot. Read more
Source§fn deserialize_borrowed_atom(
slot: &mut Slot<T, Self>,
atom: Atom<'de>,
state: &mut State,
) -> Result<(), Error>
fn deserialize_borrowed_atom( slot: &mut Slot<T, Self>, atom: Atom<'de>, state: &mut State, ) -> Result<(), Error>
Deserializes an atom that borrows from the data being deserialized
into the slot. Read more
Source§fn describe_type(d: &mut dyn Describe)
fn describe_type(d: &mut dyn Describe)
Describes the Rust shape of the type. Read more
Source§fn initial_value() -> Option<T>
fn initial_value() -> Option<T>
Provides the value of a missing struct field. Read more
Source§fn deserialize_update<'out>(
value: &'out mut T,
state: &mut State,
) -> SinkHandle<'out, 'de>
fn deserialize_update<'out>( value: &'out mut T, state: &mut State, ) -> SinkHandle<'out, 'de>
Creates a sink that updates an existing value. Read more
impl Eq for Ext
Source§impl Ord for Ext
impl Ord for Ext
1.21.0 (const: unstable) · 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
1.21.0 (const: unstable) · Source§fn min(self, other: Self) -> Selfwhere
Self: Sized,
fn min(self, other: Self) -> Selfwhere
Self: Sized,
Compares and returns the minimum of two values. Read more
Source§impl PartialOrd for Ext
impl PartialOrd for Ext
Source§impl Serialize for Ext
impl Serialize for Ext
Source§fn serialize<'a>(value: &'a Self, _state: &mut State) -> Result<Emit<'a>, Error>
fn serialize<'a>(value: &'a Self, _state: &mut State) -> Result<Emit<'a>, Error>
Serializes the value.
Source§fn finish(value: &T, state: &mut State) -> Result<(), Error>
fn finish(value: &T, state: &mut State) -> Result<(), Error>
Invoked after the serialization finished. Read more
Source§fn container_shape(value: &T) -> ContainerShape
fn container_shape(value: &T) -> ContainerShape
Returns the shape of the value if it’s a map or sequence. Read more
impl StructuralPartialEq for Ext
Auto Trait Implementations§
impl Freeze for Ext
impl RefUnwindSafe for Ext
impl Send for Ext
impl Sync for Ext
impl Unpin for Ext
impl UnsafeUnpin for Ext
impl UnwindSafe for Ext
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