Struct kwap_msg::Message [−][src]
pub struct Message<PayloadC: Collection<u8>, OptC: Collection<u8> + 'static, Opts: Collection<Opt<OptC>>> where
for<'a> &'a PayloadC: IntoIterator<Item = &'a u8>,
for<'a> &'a OptC: IntoIterator<Item = &'a u8>,
for<'a> &'a Opts: IntoIterator<Item = &'a Opt<OptC>>, {
pub id: Id,
pub ty: Type,
pub ver: Version,
pub token: Token,
pub code: Code,
pub opts: Opts,
pub payload: Payload<PayloadC>,
pub __optc: PhantomData<OptC>,
}Expand description
Low-level representation of a message that has been parsed from a byte array
To convert an iterator of bytes into a Message, there is a provided trait crate::TryFromBytes.
use kwap_msg::TryFromBytes;
use kwap_msg::*;
let packet: Vec<u8> = /* bytes! */
// `VecMessage` uses `Vec` as the backing structure for byte buffers
let msg = VecMessage::try_from_bytes(packet.clone()).unwrap();
let mut opts_expected = /* create expected options */
let expected = VecMessage {
id: Id(1),
ty: Type(0),
ver: Version(1),
token: Token(tinyvec::array_vec!([u8; 8] => 254)),
opts: opts_expected,
code: Code {class: 2, detail: 5},
payload: Payload(b"hello, world!".to_vec()),
__optc: Default::default(),
};
assert_eq!(msg, expected);See RFC7252 - Message Details for context
Fields
id: Idsee Id for details
ty: Typesee Type for details
ver: Versionsee Version for details
token: Tokensee Token for details
code: Codesee Code for details
opts: Optssee opt::Opt for details
payload: Payload<PayloadC>see Payload
__optc: PhantomData<OptC>empty field using the Opt internal byte collection type
Trait Implementations
impl<PayloadC: Clone + Collection<u8>, OptC: Clone + Collection<u8> + 'static, Opts: Clone + Collection<Opt<OptC>>> Clone for Message<PayloadC, OptC, Opts> where
for<'a> &'a PayloadC: IntoIterator<Item = &'a u8>,
for<'a> &'a OptC: IntoIterator<Item = &'a u8>,
for<'a> &'a Opts: IntoIterator<Item = &'a Opt<OptC>>,
impl<PayloadC: Clone + Collection<u8>, OptC: Clone + Collection<u8> + 'static, Opts: Clone + Collection<Opt<OptC>>> Clone for Message<PayloadC, OptC, Opts> where
for<'a> &'a PayloadC: IntoIterator<Item = &'a u8>,
for<'a> &'a OptC: IntoIterator<Item = &'a u8>,
for<'a> &'a Opts: IntoIterator<Item = &'a Opt<OptC>>,
impl<PayloadC: Debug + Collection<u8>, OptC: Debug + Collection<u8> + 'static, Opts: Debug + Collection<Opt<OptC>>> Debug for Message<PayloadC, OptC, Opts> where
for<'a> &'a PayloadC: IntoIterator<Item = &'a u8>,
for<'a> &'a OptC: IntoIterator<Item = &'a u8>,
for<'a> &'a Opts: IntoIterator<Item = &'a Opt<OptC>>,
impl<PayloadC: Debug + Collection<u8>, OptC: Debug + Collection<u8> + 'static, Opts: Debug + Collection<Opt<OptC>>> Debug for Message<PayloadC, OptC, Opts> where
for<'a> &'a PayloadC: IntoIterator<Item = &'a u8>,
for<'a> &'a OptC: IntoIterator<Item = &'a u8>,
for<'a> &'a Opts: IntoIterator<Item = &'a Opt<OptC>>,
impl<P: Collection<u8>, O: Collection<u8>, Os: Collection<Opt<O>>> GetSize for Message<P, O, Os> where
for<'b> &'b P: IntoIterator<Item = &'b u8>,
for<'b> &'b O: IntoIterator<Item = &'b u8>,
for<'b> &'b Os: IntoIterator<Item = &'b Opt<O>>,
impl<P: Collection<u8>, O: Collection<u8>, Os: Collection<Opt<O>>> GetSize for Message<P, O, Os> where
for<'b> &'b P: IntoIterator<Item = &'b u8>,
for<'b> &'b O: IntoIterator<Item = &'b u8>,
for<'b> &'b Os: IntoIterator<Item = &'b Opt<O>>,
impl<PayloadC: PartialEq + Collection<u8>, OptC: PartialEq + Collection<u8> + 'static, Opts: PartialEq + Collection<Opt<OptC>>> PartialEq<Message<PayloadC, OptC, Opts>> for Message<PayloadC, OptC, Opts> where
for<'a> &'a PayloadC: IntoIterator<Item = &'a u8>,
for<'a> &'a OptC: IntoIterator<Item = &'a u8>,
for<'a> &'a Opts: IntoIterator<Item = &'a Opt<OptC>>,
impl<PayloadC: PartialEq + Collection<u8>, OptC: PartialEq + Collection<u8> + 'static, Opts: PartialEq + Collection<Opt<OptC>>> PartialEq<Message<PayloadC, OptC, Opts>> for Message<PayloadC, OptC, Opts> where
for<'a> &'a PayloadC: IntoIterator<Item = &'a u8>,
for<'a> &'a OptC: IntoIterator<Item = &'a u8>,
for<'a> &'a Opts: IntoIterator<Item = &'a Opt<OptC>>,
impl<PayloadC: PartialOrd + Collection<u8>, OptC: PartialOrd + Collection<u8> + 'static, Opts: PartialOrd + Collection<Opt<OptC>>> PartialOrd<Message<PayloadC, OptC, Opts>> for Message<PayloadC, OptC, Opts> where
for<'a> &'a PayloadC: IntoIterator<Item = &'a u8>,
for<'a> &'a OptC: IntoIterator<Item = &'a u8>,
for<'a> &'a Opts: IntoIterator<Item = &'a Opt<OptC>>,
impl<PayloadC: PartialOrd + Collection<u8>, OptC: PartialOrd + Collection<u8> + 'static, Opts: PartialOrd + Collection<Opt<OptC>>> PartialOrd<Message<PayloadC, OptC, Opts>> for Message<PayloadC, OptC, Opts> where
for<'a> &'a PayloadC: IntoIterator<Item = &'a u8>,
for<'a> &'a OptC: IntoIterator<Item = &'a u8>,
for<'a> &'a Opts: IntoIterator<Item = &'a Opt<OptC>>,
This method returns an ordering between self and other values if one exists. Read more
This method tests less than (for self and other) and is used by the < operator. Read more
This method tests less than or equal to (for self and other) and is used by the <=
operator. Read more
This method tests greater than (for self and other) and is used by the > operator. Read more
impl<'a, P: Collection<u8>, O: Collection<u8>, Os: Collection<Opt<O>>> TryFromBytes<&'a u8> for Message<P, O, Os> where
for<'b> &'b P: IntoIterator<Item = &'b u8>,
for<'b> &'b O: IntoIterator<Item = &'b u8>,
for<'b> &'b Os: IntoIterator<Item = &'b Opt<O>>,
impl<'a, P: Collection<u8>, O: Collection<u8>, Os: Collection<Opt<O>>> TryFromBytes<&'a u8> for Message<P, O, Os> where
for<'b> &'b P: IntoIterator<Item = &'b u8>,
for<'b> &'b O: IntoIterator<Item = &'b u8>,
for<'b> &'b Os: IntoIterator<Item = &'b Opt<O>>,
type Error = MessageParseError
type Error = MessageParseError
Error type yielded if conversion fails
Try to convert from some sequence of bytes T
into Self Read more
impl<P: Collection<u8>, O: Collection<u8>, Os: Collection<Opt<O>>> TryFromBytes<u8> for Message<P, O, Os> where
for<'b> &'b P: IntoIterator<Item = &'b u8>,
for<'b> &'b O: IntoIterator<Item = &'b u8>,
for<'b> &'b Os: IntoIterator<Item = &'b Opt<O>>,
impl<P: Collection<u8>, O: Collection<u8>, Os: Collection<Opt<O>>> TryFromBytes<u8> for Message<P, O, Os> where
for<'b> &'b P: IntoIterator<Item = &'b u8>,
for<'b> &'b O: IntoIterator<Item = &'b u8>,
for<'b> &'b Os: IntoIterator<Item = &'b Opt<O>>,
type Error = MessageParseError
type Error = MessageParseError
Error type yielded if conversion fails
Try to convert from some sequence of bytes T
into Self Read more
impl<P: Collection<u8>, O: Collection<u8>, Os: Collection<Opt<O>>> TryIntoBytes for Message<P, O, Os> where
for<'b> &'b P: IntoIterator<Item = &'b u8>,
for<'b> &'b O: IntoIterator<Item = &'b u8>,
for<'b> &'b Os: IntoIterator<Item = &'b Opt<O>>,
impl<P: Collection<u8>, O: Collection<u8>, Os: Collection<Opt<O>>> TryIntoBytes for Message<P, O, Os> where
for<'b> &'b P: IntoIterator<Item = &'b u8>,
for<'b> &'b O: IntoIterator<Item = &'b u8>,
for<'b> &'b Os: IntoIterator<Item = &'b Opt<O>>,
type Error = MessageToBytesError
fn try_into_bytes<C: Collection<u8>>(self) -> Result<C, Self::Error> where
for<'a> &'a C: IntoIterator<Item = &'a u8>,
fn try_into_bytes<C: Collection<u8>>(self) -> Result<C, Self::Error> where
for<'a> &'a C: IntoIterator<Item = &'a u8>,
Try to convert into a collection of bytes Read more
impl<PayloadC: Collection<u8>, OptC: Collection<u8> + 'static, Opts: Collection<Opt<OptC>>> StructuralPartialEq for Message<PayloadC, OptC, Opts> where
for<'a> &'a PayloadC: IntoIterator<Item = &'a u8>,
for<'a> &'a OptC: IntoIterator<Item = &'a u8>,
for<'a> &'a Opts: IntoIterator<Item = &'a Opt<OptC>>,
Auto Trait Implementations
impl<PayloadC, OptC, Opts> RefUnwindSafe for Message<PayloadC, OptC, Opts> where
OptC: RefUnwindSafe,
Opts: RefUnwindSafe,
PayloadC: RefUnwindSafe,
impl<PayloadC, OptC, Opts> Send for Message<PayloadC, OptC, Opts> where
OptC: Send,
Opts: Send,
PayloadC: Send,
impl<PayloadC, OptC, Opts> Sync for Message<PayloadC, OptC, Opts> where
OptC: Sync,
Opts: Sync,
PayloadC: Sync,
impl<PayloadC, OptC, Opts> Unpin for Message<PayloadC, OptC, Opts> where
OptC: Unpin,
Opts: Unpin,
PayloadC: Unpin,
impl<PayloadC, OptC, Opts> UnwindSafe for Message<PayloadC, OptC, Opts> where
OptC: UnwindSafe,
Opts: UnwindSafe,
PayloadC: UnwindSafe,
Blanket Implementations
Mutably borrows from an owned value. Read more
