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_into<'out>(
out: &'out mut Option<Self>,
state: &mut State,
) -> SinkHandle<'out, 'de>
fn deserialize_into<'out>( out: &'out mut Option<Self>, state: &mut State, ) -> SinkHandle<'out, 'de>
Creates a sink that deserializes the value into the given slot. Read more
Source§fn initial_value() -> Option<Self>
fn initial_value() -> Option<Self>
Provides the value of a missing struct field. Read more
Source§fn deserialize_update<'out>(
value: &'out mut Self,
state: &mut State,
) -> SinkHandle<'out, 'de>
fn deserialize_update<'out>( value: &'out mut Self, 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(&self, _state: &mut State) -> Result<Chunk<'_>, Error>
fn serialize(&self, _state: &mut State) -> Result<Chunk<'_>, Error>
Serializes this serializable.
Source§fn finish(&self, _state: &mut State) -> Result<(), Error>
fn finish(&self, _state: &mut State) -> Result<(), Error>
Invoked after the serialization finished. Read more
Source§fn is_optional(&self) -> bool
fn is_optional(&self) -> bool
Checks if the current value that would be serialized represents an
optional value. Read more
Source§fn container_shape(&self) -> ContainerShape
fn container_shape(&self) -> ContainerShape
Returns the shape of this 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