Skip to main content

BatchView

Enum BatchView 

Source
pub enum BatchView<'a, I> {
    Owned(Vec<I>),
    Borrowed(&'a mut [I], usize),
}
Expand description

An internal batch container used by the runtime/nodelink/stepcontext.

Generic over the stored item I. Commonly I = Message<P>, but by using a stored-item generic the same type works for any Edge whose Item is a Payload-implementing type.

  • Owned(Vec<I>): when alloc feature is enabled and we can own a Vec.
  • Borrowed(&'a mut [I], len): stack/heapless-backed buffer with explicit length.

Variants§

§

Owned(Vec<I>)

Owned variant (alloc-enabled). Stores the entire Vec<I>.

§

Borrowed(&'a mut [I], usize)

Borrowed variant: a mutable slice plus a length indicating the valid prefix.

Implementations§

Source§

impl<'a, I> BatchView<'a, I>

Source

pub fn from_owned(v: Vec<I>) -> Self

Construct from an owned Vec (alloc feature required).

Source

pub fn from_borrowed(buf: &'a mut [I], len: usize) -> Self

Construct from a borrowed slice + length.

Source

pub fn len(&self) -> usize

Number of items in the batch.

Source

pub fn is_empty(&self) -> bool

Is the batch empty?

Source

pub fn iter(&self) -> Iter<'_, I>

Immutable iterator over items.

Source

pub fn iter_mut(&mut self) -> IterMut<'_, I>

Mutable iterator over items.

Source

pub fn as_slice(&self) -> &[I]

Return an immutable slice over the valid items.

Source§

impl<'a, P: Payload> BatchView<'a, Message<P>>

Special-case helpers for the common stored-item type: Message<P>.

Source

pub fn as_batch(&self) -> Batch<'_, P>

Convert to the public, borrowed Batch<'_, P> view.

This is only available when the stored item is Message<P>.

Source

pub fn first_header_mut(&mut self) -> Option<&mut MessageHeader>

Mutable access to the first message header if present.

Source

pub fn last_header_mut(&mut self) -> Option<&mut MessageHeader>

Mutable access to the last message header if present.

Source

pub fn into_batch_ref(&self) -> Batch<'_, P>

Try to convert into a borrowed Batch<'_, P> while keeping self alive. Equivalent to self.as_batch() but offered for clarity.

Source

pub fn into_owned<'b>(self) -> BatchView<'b, Message<P>>
where Message<P>: Clone,

Convert this batch view into an owned batch view.

This is required by mutex-backed edges: a borrowed batch cannot escape the lock guard.

Semantics:

  • If already Owned, the inner Vec is forwarded.
  • If Borrowed, the valid prefix is cloned into a new Vec.

The returned BatchView is Owned and does not borrow from the original 'a.

Source

pub fn into_vec(self) -> Vec<Message<P>>
where P: Clone,

Consume and return an owned Vec<Message<P>>.

  • If this BatchView is Owned, returns the inner Vec without copying.
  • If this BatchView is Borrowed, clones the valid prefix into a new Vec.

Alloc-only.

Trait Implementations§

Source§

impl<'a, I: Debug> Debug for BatchView<'a, I>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<'a, P: Payload> Payload for &'a BatchView<'a, Message<P>>

Source§

fn buffer_descriptor(&self) -> BufferDescriptor

Return a descriptor containing the byte size of this payload.
Source§

impl<'a, P: Payload> Payload for BatchView<'a, Message<P>>

Source§

fn buffer_descriptor(&self) -> BufferDescriptor

Return a descriptor containing the byte size of this payload.

Auto Trait Implementations§

§

impl<'a, I> Freeze for BatchView<'a, I>

§

impl<'a, I> RefUnwindSafe for BatchView<'a, I>
where I: RefUnwindSafe,

§

impl<'a, I> Send for BatchView<'a, I>
where I: Send,

§

impl<'a, I> Sync for BatchView<'a, I>
where I: Sync,

§

impl<'a, I> Unpin for BatchView<'a, I>
where I: Unpin,

§

impl<'a, I> UnsafeUnpin for BatchView<'a, I>

§

impl<'a, I> !UnwindSafe for BatchView<'a, I>

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.