pub struct SendBuffer { /* private fields */ }Expand description
An owned, writable “zero-copy” software bus message buffer.
This struct safely manages a memory buffer allocated directly from CFE’s
internal pool. You can get a writable view of it using MessageMut::from()
and then send it with zero memory copies.
If the buffer is dropped without being sent, it is automatically released back to the CFE pool, preventing memory leaks.
Implementations§
Source§impl SendBuffer
impl SendBuffer
Sourcepub fn new(size: usize) -> Result<Self>
pub fn new(size: usize) -> Result<Self>
Allocates a new zero-copy send buffer of the specified size from the CFE SB pool.
Sourcepub fn send(self, is_origination: bool) -> Result<()>
pub fn send(self, is_origination: bool) -> Result<()>
Transmits the message in this buffer.
This consumes the SendBuffer, transferring ownership of the
memory to CFE. After this call, the buffer is no longer
accessible from Rust.
On failure, the caller still owns the buffer (state is
unchanged) and the Drop impl will release it.
§Arguments
is_origination: Set totrueto have CFE automatically fill in fields like sequence count and timestamp. Set tofalsewhen forwarding a message.
Sourcepub fn view(&mut self) -> MessageMut<'_>
pub fn view(&mut self) -> MessageMut<'_>
Returns a read-only slice view of the buffer’s contents.
Sourcepub fn as_mut_slice(&mut self) -> &mut [u8]
pub fn as_mut_slice(&mut self) -> &mut [u8]
Returns the raw mutable byte slice of the buffer’s contents.