[][src]Struct libzmq::Msg

pub struct Msg { /* fields omitted */ }

A handle to a message owned by ØMQ.

A ØMQ message is a discrete unit of data passed between applications or components of the same application. ØMQ messages have no internal structure and from the point of view of ØMQ itself they are considered to be opaque binary data.

Methods

impl Msg[src]

pub fn new() -> Self[src]

Create an empty Msg.

See zmq_msg_init.

use libzmq::Msg;

let msg = Msg::new();

assert!(msg.is_empty());

pub fn with_size(size: usize) -> Self[src]

Create a Msg preallocated with len zeroed bytes.

See zmq_msg_init_size.

use libzmq::Msg;

let size = 420;
let msg = Msg::with_size(size);

assert_eq!(msg.len(), size);

pub fn len(&self) -> usize[src]

Returns the message content size in bytes.

See zmq_msg_size.

pub fn is_empty(&self) -> bool[src]

Returns true if the message content has size zero.

pub fn to_str(&self) -> Result<&str, Utf8Error>[src]

Return the message content as a str slice if it is valid UTF-8.

use libzmq::Msg;

let text = "blzit";
let msg = Msg::from(text);

assert_eq!(msg.to_str()?, text);

pub fn as_bytes(&self) -> &[u8][src]

Return the message content as a byte slice.

use libzmq::Msg;

let bytes: &[u8] = b"blzit";
let msg = Msg::from(bytes);

assert_eq!(msg.as_bytes(), bytes);

pub fn as_bytes_mut(&mut self) -> &mut [u8][src]

Return the message content as a mutable byte slice.

pub fn routing_id(&self) -> Option<RoutingId>[src]

Get routing ID property on the message.

See zmq_msg_routing_id.

pub fn set_routing_id(&mut self, routing_id: RoutingId)[src]

Set routing ID property on the message.

Usage Contract

  • Cannot be zero

Returned Error Variants

See zmq_msg_set_routing_id.

pub fn group(&self) -> Option<&GroupSlice>[src]

The group property on the message.

pub fn set_group<G>(&mut self, group: G) where
    G: AsRef<GroupSlice>, 
[src]

Set the group property on the message.

use libzmq::{Msg, Group};
use std::convert::TryInto;

let a: Group = "A".try_into()?;

let mut msg: Msg = "some msg".into();
msg.set_group(&a);
assert_eq!(a, msg.group().unwrap());

Usage Contract

  • Cannot hold more than 15 characters.

Returned Error Variants

Trait Implementations

impl Eq for Msg[src]

impl PartialEq<Msg> for Msg[src]

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

Compares the two underlying raw C pointers.

#[must_use]
fn ne(&self, other: &Rhs) -> bool
1.0.0[src]

This method tests for !=.

impl Drop for Msg[src]

fn drop(&mut self)[src]

Releases the ØMQ message.

See zmq_msg_close.

impl Clone for Msg[src]

fn clone(&self) -> Self[src]

Copy the content of the message into another message.

See zmq_msg_copy.

fn clone_from(&mut self, source: &Self)1.0.0[src]

Performs copy-assignment from source. Read more

impl From<Box<[u8]>> for Msg[src]

fn from(data: Box<[u8]>) -> Msg[src]

Converts of box of bytes into a Msg without copying.

impl<'a, '_> From<&'_ [u8]> for Msg[src]

fn from(slice: &[u8]) -> Self[src]

Converts a byte slice into a Msg by copying.

impl From<[u8; 0]> for Msg[src]

fn from(array: [u8; 0]) -> Self[src]

Converts an array into a Msg without copying.

impl From<[u8; 1]> for Msg[src]

fn from(array: [u8; 1]) -> Self[src]

Converts an array into a Msg without copying.

impl From<[u8; 2]> for Msg[src]

fn from(array: [u8; 2]) -> Self[src]

Converts an array into a Msg without copying.

impl From<[u8; 3]> for Msg[src]

fn from(array: [u8; 3]) -> Self[src]

Converts an array into a Msg without copying.

impl From<[u8; 4]> for Msg[src]

fn from(array: [u8; 4]) -> Self[src]

Converts an array into a Msg without copying.

impl From<[u8; 5]> for Msg[src]

fn from(array: [u8; 5]) -> Self[src]

Converts an array into a Msg without copying.

impl From<[u8; 6]> for Msg[src]

fn from(array: [u8; 6]) -> Self[src]

Converts an array into a Msg without copying.

impl From<[u8; 7]> for Msg[src]

fn from(array: [u8; 7]) -> Self[src]

Converts an array into a Msg without copying.

impl From<[u8; 8]> for Msg[src]

fn from(array: [u8; 8]) -> Self[src]

Converts an array into a Msg without copying.

impl From<[u8; 9]> for Msg[src]

fn from(array: [u8; 9]) -> Self[src]

Converts an array into a Msg without copying.

impl From<[u8; 10]> for Msg[src]

fn from(array: [u8; 10]) -> Self[src]

Converts an array into a Msg without copying.

impl From<[u8; 11]> for Msg[src]

fn from(array: [u8; 11]) -> Self[src]

Converts an array into a Msg without copying.

impl From<[u8; 12]> for Msg[src]

fn from(array: [u8; 12]) -> Self[src]

Converts an array into a Msg without copying.

impl From<[u8; 13]> for Msg[src]

fn from(array: [u8; 13]) -> Self[src]

Converts an array into a Msg without copying.

impl From<[u8; 14]> for Msg[src]

fn from(array: [u8; 14]) -> Self[src]

Converts an array into a Msg without copying.

impl From<[u8; 15]> for Msg[src]

fn from(array: [u8; 15]) -> Self[src]

Converts an array into a Msg without copying.

impl From<[u8; 16]> for Msg[src]

fn from(array: [u8; 16]) -> Self[src]

Converts an array into a Msg without copying.

impl From<[u8; 17]> for Msg[src]

fn from(array: [u8; 17]) -> Self[src]

Converts an array into a Msg without copying.

impl From<[u8; 18]> for Msg[src]

fn from(array: [u8; 18]) -> Self[src]

Converts an array into a Msg without copying.

impl From<[u8; 19]> for Msg[src]

fn from(array: [u8; 19]) -> Self[src]

Converts an array into a Msg without copying.

impl From<[u8; 20]> for Msg[src]

fn from(array: [u8; 20]) -> Self[src]

Converts an array into a Msg without copying.

impl From<[u8; 21]> for Msg[src]

fn from(array: [u8; 21]) -> Self[src]

Converts an array into a Msg without copying.

impl From<[u8; 22]> for Msg[src]

fn from(array: [u8; 22]) -> Self[src]

Converts an array into a Msg without copying.

impl From<[u8; 23]> for Msg[src]

fn from(array: [u8; 23]) -> Self[src]

Converts an array into a Msg without copying.

impl From<[u8; 24]> for Msg[src]

fn from(array: [u8; 24]) -> Self[src]

Converts an array into a Msg without copying.

impl From<[u8; 25]> for Msg[src]

fn from(array: [u8; 25]) -> Self[src]

Converts an array into a Msg without copying.

impl From<[u8; 26]> for Msg[src]

fn from(array: [u8; 26]) -> Self[src]

Converts an array into a Msg without copying.

impl From<[u8; 27]> for Msg[src]

fn from(array: [u8; 27]) -> Self[src]

Converts an array into a Msg without copying.

impl From<[u8; 28]> for Msg[src]

fn from(array: [u8; 28]) -> Self[src]

Converts an array into a Msg without copying.

impl From<[u8; 29]> for Msg[src]

fn from(array: [u8; 29]) -> Self[src]

Converts an array into a Msg without copying.

impl From<[u8; 30]> for Msg[src]

fn from(array: [u8; 30]) -> Self[src]

Converts an array into a Msg without copying.

impl From<[u8; 31]> for Msg[src]

fn from(array: [u8; 31]) -> Self[src]

Converts an array into a Msg without copying.

impl From<[u8; 32]> for Msg[src]

fn from(array: [u8; 32]) -> Self[src]

Converts an array into a Msg without copying.

impl From<Vec<u8>> for Msg[src]

fn from(bytes: Vec<u8>) -> Self[src]

Converts a byte vector into a Msg without copying.

impl<'a> From<&'a str> for Msg[src]

fn from(text: &str) -> Self[src]

Converts a str slice into a Msg by copying.

impl From<String> for Msg[src]

fn from(text: String) -> Self[src]

Converts a String into a Msg by without copying.

impl<'a, T> From<&'a T> for Msg where
    T: Into<Msg> + Clone
[src]

impl Default for Msg[src]

fn default() -> Self[src]

Initialises an empty ØMQ message.

See zmq_msg_init.

impl Debug for Msg[src]

Auto Trait Implementations

impl Send for Msg

impl Sync for Msg

Blanket Implementations

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> From<T> for T[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> Any for T where
    T: 'static + ?Sized
[src]