pub struct Message {
pub payload_len: usize,
pub user_defined: u32,
pub is_fin: bool,
pub is_continuation: bool,
pub is_padding: bool,
/* private fields */
}Expand description
Contains coordinates to some payload at particular point in time. Messages are consumer in a
‘lazily’ way that’s why it’s safe to clone() and pass them around. When message is read
(consumed) it can result in overrun error if the producer has lapped around.
Fields§
§payload_len: usizeMessage length.
user_defined: u32User defined field.
is_fin: boolIndicates final message fragment.
is_continuation: boolIndicates continuation frame
is_padding: boolIndicates padding frame.
Implementations§
Source§impl Message
impl Message
Sourcepub fn read(&self, buf: &mut [u8]) -> Result<usize>
pub fn read(&self, buf: &mut [u8]) -> Result<usize>
Read the message into specified buffer. It will return error if the provided buffer is too small. Will also return error if at any point the producer has overrun this consumer. On success, it will return the number of bytes written to the buffer.
§Examples
use bcast::Message;
fn consume_message(msg: &Message) {
let mut payload = [0u8; 1024];
// read into provided buffer (error means overrun)
let len = msg.read(&mut payload).unwrap();
// process payload
// ...
}Trait Implementations§
Auto Trait Implementations§
impl Freeze for Message
impl RefUnwindSafe for Message
impl Send for Message
impl Sync for Message
impl Unpin for Message
impl UnwindSafe for Message
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more