pub struct SpscSender { /* private fields */ }Expand description
SPSC producer handle for a SharedLayout events region.
Semantics (v1):
- at-most-once delivery
- bounded capacity;
publish*returnsError::Fullwhen the region cannot accept more - a successful
publish*commits bytes that a receiver will observe on successful receive
Implementations§
Source§impl SpscSender
impl SpscSender
Sourcepub fn publish(&self, data: &[u8]) -> Result<(), Error>
pub fn publish(&self, data: &[u8]) -> Result<(), Error>
Publish a byte payload.
Returns:
Ok(())if the message was committedErr(Error::TooLarge)ifdata.len() > INDEXBUS_SLOT_DATA_SIZEErr(Error::Full)if bounded capacity is exhausted
Sourcepub fn publish_with<F, E>(&self, f: F) -> Result<(), PublishWithError<E>>
pub fn publish_with<F, E>(&self, f: F) -> Result<(), PublishWithError<E>>
Publish by writing directly into the slot buffer.
This avoids intermediate allocations/copies for higher-level adapters.
The closure must return the number of bytes written. That length becomes the published message length.
§Errors
PublishWithError::Encode: the closure returned an error; no message is published.PublishWithError::Core: capacity/layout failures (e.g. full), orlen > INDEXBUS_SLOT_DATA_SIZE.
Sourcepub fn try_publish_slot(&self, slot: EventsSlot) -> Result<(), PublishSlotError>
pub fn try_publish_slot(&self, slot: EventsSlot) -> Result<(), PublishSlotError>
Publish a previously-received slot by forwarding its slot index into this sender’s queue.
On failure, returns the original slot back to the caller.
Sourcepub fn publish_slot(&self, slot: EventsSlot) -> Result<(), Error>
pub fn publish_slot(&self, slot: EventsSlot) -> Result<(), Error>
Publish a previously-received slot, discarding it on failure.
Trait Implementations§
impl Send for SpscSender
Auto Trait Implementations§
impl Freeze for SpscSender
impl !RefUnwindSafe for SpscSender
impl !Sync for SpscSender
impl Unpin for SpscSender
impl !UnwindSafe for SpscSender
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