[−][src]Struct async_zmq_types::Multipart
This type is used for receiving and sending messages in Multipart groups. An application could make using this easier by implementing traits as follows:
extern crate zmq; extern crate tokio_zmq; use tokio_zmq::Multipart; #[derive(Debug)] enum Error { NotEnoughMessages, TooManyMessages, } struct Envelope { filter: zmq::Message, address: zmq::Message, body: zmq::Message, } impl Envelope { fn from_multipart(mut multipart: Multipart) -> Result<Self, Error> { let filter = multipart.pop_front().ok_or(Error::NotEnoughMessages)?; let address = multipart.pop_front().ok_or(Error::NotEnoughMessages)?; let body = multipart.pop_front().ok_or(Error::NotEnoughMessages)?; if !multipart.is_empty() { return Err(Error::TooManyMessages); } Ok(Envelope { filter, address, body, }) } } impl From<Envelope> for Multipart { fn from(envelope: Envelope) -> Self { let mut multipart = Multipart::new(); multipart.push_back(envelope.filter); multipart.push_back(envelope.address); multipart.push_back(envelope.body); multipart } } fn main() { let mut multipart: Multipart = Multipart::new(); multipart.push_back(zmq::Message::from_slice(b"FILTER: asdf")); multipart.push_back(zmq::Message::from_slice(b"some.address")); multipart.push_back(zmq::Message::from_slice(b"Some content")); let envelope = Envelope::from_multipart(multipart).unwrap(); let multipart2: Multipart = envelope.into(); }
Methods
impl Multipart
[src]
impl Multipart
pub fn new() -> Self | [src] |
pub fn into_inner(self) -> VecDeque<Message> | [src] |
pub fn get(&self, index: usize) -> Option<&Message> | [src] |
pub fn pop_front(&mut self) -> Option<Message> | [src] |
pub fn pop_back(&mut self) -> Option<Message> | [src] |
pub fn push_front(&mut self, msg: Message) | [src] |
pub fn push_back(&mut self, msg: Message) | [src] |
pub fn is_empty(&self) -> bool | [src] |
pub fn iter(&self) -> Iter<Message> | [src] |
pub fn len(&self) -> usize | [src] |
pub fn iter_mut(&mut self) -> IterMut<Message> | [src] |
pub fn drain<R>(&mut self, range: R) -> Drain<Message> where | [src] |
Trait Implementations
impl From<Message> for Multipart
[src]
impl From<Message> for Multipart
impl From<Vec<Message>> for Multipart
[src]
impl From<Vec<Message>> for Multipart
impl<'a> IntoIterator for &'a Multipart
[src]
impl<'a> IntoIterator for &'a Multipart
type Item = &'a Message
The type of the elements being iterated over.
type IntoIter = Iter<'a, Message>
Which kind of iterator are we turning this into?
fn into_iter(self) -> Iter<'a, Message> | [src] |
impl IntoIterator for Multipart
[src]
impl IntoIterator for Multipart
type Item = Message
The type of the elements being iterated over.
type IntoIter = IntoIter<Message>
Which kind of iterator are we turning this into?
fn into_iter(self) -> IntoIter<Message> | [src] |
impl<'a> IntoIterator for &'a mut Multipart
[src]
impl<'a> IntoIterator for &'a mut Multipart
type Item = &'a mut Message
The type of the elements being iterated over.
type IntoIter = IterMut<'a, Message>
Which kind of iterator are we turning this into?
fn into_iter(self) -> IterMut<'a, Message> | [src] |
impl Default for Multipart
[src]
impl Default for Multipart
impl Debug for Multipart
[src]
impl Debug for Multipart
Auto Trait Implementations
Blanket Implementations
impl<T> From for T
[src]
impl<T> From for T
impl<I> IntoIterator for I where
I: Iterator,
[src]
impl<I> IntoIterator for I where
I: Iterator,
type Item = <I as Iterator>::Item
The type of the elements being iterated over.
type IntoIter = I
Which kind of iterator are we turning this into?
fn into_iter(self) -> I | [src] |
impl<T, U> Into for T where
U: From<T>,
[src]
impl<T, U> Into for T where
U: From<T>,
impl<T, U> TryFrom for T where
T: From<U>,
[src]
impl<T, U> TryFrom for T where
T: From<U>,
type Error = !
🔬 This is a nightly-only experimental API. (
try_from
)The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error> | [src] |
impl<T> Borrow for T where
T: ?Sized,
[src]
impl<T> Borrow for T where
T: ?Sized,
impl<T> BorrowMut for T where
T: ?Sized,
[src]
impl<T> BorrowMut for T where
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T | [src] |
impl<T, U> TryInto for T where
U: TryFrom<T>,
[src]
impl<T, U> TryInto for T where
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
🔬 This is a nightly-only experimental API. (
try_from
)The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error> | [src] |
impl<T> Any for T where
T: 'static + ?Sized,
[src]
impl<T> Any for T where
T: 'static + ?Sized,
fn get_type_id(&self) -> TypeId | [src] |