Skip to main content

PublishLoan

Struct PublishLoan 

Source
pub struct PublishLoan<'a, const TX_BUF: usize> { /* private fields */ }
Expand description

Writable loan into a EmbeddedRawPublisher’s slot.

User fills as_mut() then calls commit to publish, or discard to release the slot without publishing. Dropping without either silently discards (slot freed); a #[must_use] warning catches accidental drops at compile time.

Two backings, selected at compile time by the rmw-lending feature:

  • Arena (default): per-publisher inline [u8; TX_BUF] slot. On commit, publish_raw memcpys into the backend’s outbound buffer.
  • Backend lending (rmw-lending): slot owned by the backend (zenoh-pico’s static buffer aliased via z_bytes_from_static_buf, XRCE’s ucdrBuffer reservation). True zero-copy publish.

Implementations§

Source§

impl<'a, const TX_BUF: usize> PublishLoan<'a, TX_BUF>

Source

pub fn as_mut(&mut self) -> &mut [u8]

Mutable view into the loaned bytes. Caller writes message data here.

Source

pub fn commit(self) -> Result<(), LoanError>

Commit the loan: hand the bytes to the backend’s publish_raw, then release the arena slot. Returns the backend’s publish error if any (slot is released regardless).

Source

pub fn discard(self)

Discard the loan without publishing. Equivalent to dropping, but explicit (no #[must_use] warning).

Trait Implementations§

Source§

impl<'a, const TX_BUF: usize> Drop for PublishLoan<'a, TX_BUF>

Available on non-crate feature rmw-lending only.
Source§

fn drop(&mut self)

Executes the destructor for this type. Read more

Auto Trait Implementations§

§

impl<'a, const TX_BUF: usize> Freeze for PublishLoan<'a, TX_BUF>

§

impl<'a, const TX_BUF: usize> !RefUnwindSafe for PublishLoan<'a, TX_BUF>

§

impl<'a, const TX_BUF: usize> !Send for PublishLoan<'a, TX_BUF>

§

impl<'a, const TX_BUF: usize> !Sync for PublishLoan<'a, TX_BUF>

§

impl<'a, const TX_BUF: usize> Unpin for PublishLoan<'a, TX_BUF>

§

impl<'a, const TX_BUF: usize> UnsafeUnpin for PublishLoan<'a, TX_BUF>

§

impl<'a, const TX_BUF: usize> !UnwindSafe for PublishLoan<'a, TX_BUF>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.