[−][src]Struct libzmq::Msg
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
InvalidInput
(if contract is not followed)
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]
G: AsRef<GroupSlice>,
Set the group property on the message.
use libzmq::{prelude::TryInto, Msg, Group}; 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
InvalidInput
(if contract is not followed)
Trait Implementations
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 Eq for Msg
[src]
impl Default for Msg
[src]
fn default() -> Self
[src]
Initialises an empty ØMQ message.
See zmq_msg_init
.
impl From<Box<[u8]>> for Msg
[src]
impl<'a, '_> From<&'_ [u8]> for Msg
[src]
impl From<[u8; 0]> for Msg
[src]
impl From<[u8; 1]> for Msg
[src]
impl From<[u8; 2]> for Msg
[src]
impl From<[u8; 3]> for Msg
[src]
impl From<[u8; 4]> for Msg
[src]
impl From<[u8; 5]> for Msg
[src]
impl From<[u8; 6]> for Msg
[src]
impl From<[u8; 7]> for Msg
[src]
impl From<[u8; 8]> for Msg
[src]
impl From<[u8; 9]> for Msg
[src]
impl From<[u8; 10]> for Msg
[src]
impl From<[u8; 11]> for Msg
[src]
impl From<[u8; 12]> for Msg
[src]
impl From<[u8; 13]> for Msg
[src]
impl From<[u8; 14]> for Msg
[src]
impl From<[u8; 15]> for Msg
[src]
impl From<[u8; 16]> for Msg
[src]
impl From<[u8; 17]> for Msg
[src]
impl From<[u8; 18]> for Msg
[src]
impl From<[u8; 19]> for Msg
[src]
impl From<[u8; 20]> for Msg
[src]
impl From<[u8; 21]> for Msg
[src]
impl From<[u8; 22]> for Msg
[src]
impl From<[u8; 23]> for Msg
[src]
impl From<[u8; 24]> for Msg
[src]
impl From<[u8; 25]> for Msg
[src]
impl From<[u8; 26]> for Msg
[src]
impl From<[u8; 27]> for Msg
[src]
impl From<[u8; 28]> for Msg
[src]
impl From<[u8; 29]> for Msg
[src]
impl From<[u8; 30]> for Msg
[src]
impl From<[u8; 31]> for Msg
[src]
impl From<[u8; 32]> for Msg
[src]
impl From<Vec<u8>> for Msg
[src]
impl<'a> From<&'a str> for Msg
[src]
impl From<String> for Msg
[src]
impl<'a, T> From<&'a T> for Msg where
T: Into<Msg> + Clone,
[src]
T: Into<Msg> + Clone,
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 Debug for Msg
[src]
Auto Trait Implementations
impl Send for Msg
impl Unpin for Msg
impl Sync for Msg
impl UnwindSafe for Msg
impl RefUnwindSafe for Msg
Blanket Implementations
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
fn to_owned(&self) -> T
[src]
fn clone_into(&self, target: &mut T)
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
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, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,