Skip to main content

MessagePack

Struct MessagePack 

Source
pub struct MessagePack<'a> { /* private fields */ }
Expand description

A borrowed, structurally checked message pack.

MessagePack::parse applies the same rules as the reference library: the single message size must be 25, the pack must hold 1 to 9 messages, it may contain no nested packs or unknown types, and at most one Location, Self ID, System and Operator ID message. Individual messages are decoded lazily by MessagePack::messages.

Implementations§

Source§

impl<'a> MessagePack<'a>

Source

pub fn parse(data: &'a [u8]) -> Result<Self, Error>

Parses a pack that starts at data[0] (the pack header byte). Bytes after the last message are ignored.

Source

pub fn protocol_version(&self) -> u8

Protocol version from the pack header.

Source

pub fn len(&self) -> usize

Number of messages in the pack.

Source

pub fn is_empty(&self) -> bool

Always false: a valid pack holds at least one message.

Source

pub fn encoded_len(&self) -> usize

Size of the encoded pack in bytes, header included.

Source

pub fn raw_messages(&self) -> impl Iterator<Item = &'a [u8; 25]> + 'a

The raw 25 byte messages.

Source

pub fn messages(&self) -> impl Iterator<Item = Result<Message, Error>> + 'a

Decodes each message in turn. A message that fails to decode (for example an Auth page with an inconsistent header) yields its error without stopping the others.

Trait Implementations§

Source§

impl<'a> Clone for MessagePack<'a>

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<'a> Copy for MessagePack<'a>

Source§

impl<'a> Debug for MessagePack<'a>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<'a> Eq for MessagePack<'a>

Source§

impl<'a> PartialEq for MessagePack<'a>

Source§

fn eq(&self, other: &Self) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl<'a> StructuralPartialEq for MessagePack<'a>

Auto Trait Implementations§

§

impl<'a> Forget for MessagePack<'a>

§

impl<'a> Freeze for MessagePack<'a>

§

impl<'a> Move for MessagePack<'a>

§

impl<'a> RefUnwindSafe for MessagePack<'a>

§

impl<'a> Send for MessagePack<'a>

§

impl<'a> Sync for MessagePack<'a>

§

impl<'a> Unpin for MessagePack<'a>

§

impl<'a> UnsafeUnpin for MessagePack<'a>

§

impl<'a> UnwindSafe for MessagePack<'a>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.