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>): whenallocfeature 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>
impl<'a, I> BatchView<'a, I>
Sourcepub fn from_owned(v: Vec<I>) -> Self
pub fn from_owned(v: Vec<I>) -> Self
Construct from an owned Vec (alloc feature required).
Sourcepub fn from_borrowed(buf: &'a mut [I], len: usize) -> Self
pub fn from_borrowed(buf: &'a mut [I], len: usize) -> Self
Construct from a borrowed slice + length.
Source§impl<'a, P: Payload> BatchView<'a, Message<P>>
Special-case helpers for the common stored-item type: Message<P>.
impl<'a, P: Payload> BatchView<'a, Message<P>>
Special-case helpers for the common stored-item type: Message<P>.
Sourcepub fn as_batch(&self) -> Batch<'_, P>
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>.
Sourcepub fn first_header_mut(&mut self) -> Option<&mut MessageHeader>
pub fn first_header_mut(&mut self) -> Option<&mut MessageHeader>
Mutable access to the first message header if present.
Sourcepub fn last_header_mut(&mut self) -> Option<&mut MessageHeader>
pub fn last_header_mut(&mut self) -> Option<&mut MessageHeader>
Mutable access to the last message header if present.
Sourcepub fn into_batch_ref(&self) -> Batch<'_, P>
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.
Sourcepub fn into_owned<'b>(self) -> BatchView<'b, Message<P>>
pub fn into_owned<'b>(self) -> BatchView<'b, Message<P>>
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 innerVecis forwarded. - If
Borrowed, the valid prefix is cloned into a newVec.
The returned BatchView is Owned and does not borrow from the original 'a.