Skip to main content

FrameRef

Struct FrameRef 

Source
pub struct FrameRef<N: Node + ?Sized>(/* private fields */);
Expand description

Reference to a VPP node frame

A &mut FrameRef corresponds to vlib_frame_t * in C.

Implementations§

Source§

impl<N: Node + ?Sized> FrameRef<N>

Source

pub unsafe fn from_ptr_mut<'a>(ptr: *mut vlib_frame_t) -> &'a mut Self

Creates a &mut FrameRef directly from a pointer

§Safety
  • The pointer must be valid and a properly initialised vlib_frame_t.
  • The pointer must stay valid and the contents must not be mutated for the duration of the lifetime of the returned object.
  • scalar_offset, vector_offset, and aux_offset must be set correctly to point to the valid, initialised data areas in the frame, and n_vectors must be set correctly to indicate the number of valid vector and aux elements.
Source

pub fn as_ptr(&self) -> *mut vlib_frame_t

Returns the raw pointer to the underlying vlib_frame_t

Source

pub fn vector(&self) -> &[N::Vector]

Returns the vector data elements in the frame as a slice

Source

pub fn scalar(&self) -> &N::Scalar

Returns the scalar data in the frame

Source

pub fn aux(&self) -> &[N::Aux]

Returns the auxiliary data elements in the frame as a slice

Note: the length of the returned slice is equal to the number of vectors in the frame.

Source§

impl<N, V> FrameRef<N>
where N: Node<Vector = V> + ?Sized, V: VectorBufferIndex,

Source

pub unsafe fn get_buffers<'me, 'vm, 'buf: 'vm + 'me, const ARRAY_N: usize>( &'me self, vm: &'vm MainRef, to: &mut ArrayVec<&'buf mut BufferRef<N::FeatureData>, ARRAY_N>, ) -> &'me [N::Vector]

Get pointers to buffers for the given buffer indices, writing them into the provided to arrayvec.

This is similar to vlib_get_buffers in the C API.

Note that although it would be more idiomatic to return an ArrayVec directly, this method takes a mutable reference to an ArrayVec to avoid an unnecessary copy when returning.

§Safety
  • The caller must ensure that to has enough capacity to hold all the buffers corresponding to the indices in from_indices.
  • Each buffer’s feature_arc_index and current_config_index must be consistent with the FeatureData type. If they are not known (i.e. because the caller the node isn’t being executed in a feature arc), FeatureData should be a zero-sized type such as ().
  • Must not be called more than once without the framing being flushed in between as Rust’s reference aliasing rules will be violated.

Auto Trait Implementations§

§

impl<N> Freeze for FrameRef<N>
where N: ?Sized,

§

impl<N> !RefUnwindSafe for FrameRef<N>

§

impl<N> !Send for FrameRef<N>

§

impl<N> !Sync for FrameRef<N>

§

impl<N> Unpin for FrameRef<N>
where N: Unpin + ?Sized,

§

impl<N> UnsafeUnpin for FrameRef<N>
where N: ?Sized,

§

impl<N> UnwindSafe for FrameRef<N>
where N: UnwindSafe + ?Sized,

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.