Skip to main content

NodeRegistration

Struct NodeRegistration 

Source
pub struct NodeRegistration<N: Node, const N_NEXT_NODES: usize> { /* private fields */ }
Expand description

Registration information for a VPP node

Used for registering and unregistering nodes with VPP.

This is typically created automatically using the vpp_plugin_macros::vlib_node macro.

Implementations§

Source§

impl<N: Node, const N_NEXT_NODES: usize> NodeRegistration<N, N_NEXT_NODES>

Source

pub const fn new( registration: _vlib_node_registration<[*mut c_char; N_NEXT_NODES]>, ) -> Self

Creates a new NodeRegistration from the given registration data

Source

pub unsafe fn register(&'static self)

Registers the node with VPP

§Safety
  • Must be called only once for this node registration.
  • Must be called from a constructor function that is invoked before VPP initialises.
  • The following pointers in the registration data must be valid:
    • name (must be a valid, nul-terminated string)
    • function (must point to a valid node function)
    • error_descriptions (must point to an array of n_errors valid vlib_error_desc_t entries)
    • next_nodes (each entry must be a valid nul-terminated string and length must be at least n_next_nodes)
  • Other pointers in the registration data must be either valid or null as appropriate.
  • vector_size, scalar_size, and aux_size must match the sizes of the corresponding types in N.
Source

pub unsafe fn unregister(&self)

Unregisters the node from VPP

§Safety
  • Must be called only once for this node registration.
  • Must be called from a destructor function that is invoked after VPP uninitialises.
  • The node must have been previously registered with VPP using Self::register.
Source

pub unsafe fn register_node_fn(&self, node_fn: *mut vlib_node_fn_registration_t)

Registers a node function with VPP

§Safety
  • The node_fn pointer must be valid and point to a properly initialised vlib_node_fn_registration_t.
  • The node_fn must not have been previously registered with VPP.
Source

pub unsafe fn node_runtime_from_ptr<'a>( &self, ptr: *mut vlib_node_runtime_t, ) -> &'a mut NodeRuntimeRef<N>

Creates a &mut NodeRuntimeRef directly from a pointer

This is a convenience method that calls NodeRuntimeRef::from_ptr_mut, for code that has an instance of NodeRegistration, but doesn’t know the name of the type for the node. As such, self isn’t used, it’s just taken so that the generic types are known.

§Safety
Source

pub unsafe fn frame_from_ptr<'a>( &self, ptr: *mut vlib_frame_t, ) -> &'a mut FrameRef<N>

Creates a &mut FrameRef directly from a pointer

This is a convenience method that calls FrameRef::from_ptr_mut, for code that has an instance of NodeRegistration, but doesn’t know the name of the type for the node. As such, self isn’t used, it’s just taken so that the generic types are known.

§Safety
Source

pub unsafe fn node_from_ptr<'a>( &self, ptr: *mut vlib_node_t, ) -> &'a mut NodeRef<N>

Creates a &mut NodeRef directly from a pointer

This is a convenience method that calls NodeRef::from_ptr_mut, for code that has an instance of NodeRegistration, but doesn’t know the name of the type for the node. As such, self isn’t used, it’s just taken so that the generic types are known.

§Safety
Source

pub const fn name_ptr(&self) -> *const c_char

Returns the name of the node as a pointer to a C string

Note: no guarantees are made about the validity of the pointer or the string data.

Trait Implementations§

Source§

impl<N: Node, const N_NEXT_NODES: usize> Send for NodeRegistration<N, N_NEXT_NODES>

Source§

impl<N: Node, const N_NEXT_NODES: usize> Sync for NodeRegistration<N, N_NEXT_NODES>

Auto Trait Implementations§

§

impl<N, const N_NEXT_NODES: usize> !Freeze for NodeRegistration<N, N_NEXT_NODES>

§

impl<N, const N_NEXT_NODES: usize> !RefUnwindSafe for NodeRegistration<N, N_NEXT_NODES>

§

impl<N, const N_NEXT_NODES: usize> Unpin for NodeRegistration<N, N_NEXT_NODES>
where N: Unpin,

§

impl<N, const N_NEXT_NODES: usize> UnsafeUnpin for NodeRegistration<N, N_NEXT_NODES>

§

impl<N, const N_NEXT_NODES: usize> UnwindSafe for NodeRegistration<N, N_NEXT_NODES>
where N: UnwindSafe,

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.