[−][src]Struct zmq::Message
Holds a 0MQ message.
A message is a single frame, either received or created locally and then
sent over the wire. Multipart messages are transmitted as multiple
Message
s.
In rust-zmq, you aren't required to create message objects if you use the
convenience APIs provided (e.g. Socket::recv_bytes()
or
Socket::send()
). However, using message objects can make multiple
operations in a loop more efficient, since allocated memory can be reused.
Methods
impl Message
[src]
pub fn new() -> Message
[src]
Create an empty Message
.
pub unsafe fn with_capacity_unallocated(len: usize) -> Message
[src]
This method has an unintuitive name, and should not be needed.
Create a Message
preallocated with len
uninitialized bytes.
Since it is very easy to introduce undefined behavior using this function, its use is not recommended, and it will be removed in a future release. If there is a use-case that cannot be handled efficiently by the safe message constructors, please file an issue.
pub fn with_size(len: usize) -> Message
[src]
Create a Message
with space for len
bytes that are initialized to 0.
pub fn with_capacity(len: usize) -> Message
[src]
This method has a name which does not match its semantics. Use with_size
instead
Create a Message
with space for len
bytes that are initialized to 0.
pub fn from_slice(data: &[u8]) -> Message
[src]
Use the From
trait instead.
Create a Message
from a &[u8]
. This will copy data
into the message.
This is equivalent to using the From<&[u8]>
trait.
pub fn as_str(&self) -> Option<&str>
[src]
Return the message content as a string slice if it is valid UTF-8.
pub fn get_more(&self) -> bool
[src]
Return the ZMQ_MORE
flag, which indicates if more parts of a multipart
message will follow.
pub fn gets<'a>(&'a mut self, property: &str) -> Option<&'a str>
[src]
Query a message metadata property.
Non-UTF8 values
The zmq_msg_gets
man page notes "The encoding of the property and
value shall be UTF8". However, this is not actually enforced. For API
compatibility reasons, this function will return None
when
encountering a non-UTF8 value; so a missing and a non-UTF8 value cannot
currently be distinguished.
This is considered a bug in the bindings, and will be fixed with the next API-breaking release.
Trait Implementations
impl Drop for Message
[src]
impl Eq for Message
[src]
impl PartialEq<Message> for Message
[src]
impl<'a> From<&'a [u8]> for Message
[src]
impl From<Vec<u8>> for Message
[src]
impl From<Box<[u8]>> for Message
[src]
fn from(data: Box<[u8]>) -> Self
[src]
Construct a message from a boxed slice without copying the data.
impl<'a> From<&'a str> for Message
[src]
impl<'a> From<&'a String> for Message
[src]
fn from(msg: &String) -> Self
[src]
Construct a message from a string slice by copying the UTF-8 data.
impl<'a, T> From<&'a T> for Message where
T: Into<Message> + Clone,
[src]
T: Into<Message> + Clone,
impl Deref for Message
[src]
impl DerefMut for Message
[src]
impl Debug for Message
[src]
Auto Trait Implementations
impl Send for Message
impl Unpin for Message
impl Sync for Message
impl UnwindSafe for Message
impl RefUnwindSafe for Message
Blanket Implementations
impl<T> Sendable for T where
T: Into<Message>,
[src]
T: Into<Message>,
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> From<T> for T
[src]
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,