Skip to main content

ProcessNodeRegistration

Struct ProcessNodeRegistration 

Source
pub struct ProcessNodeRegistration<N: ProcessNode, const N_NEXT_NODES: usize> { /* private fields */ }
Available on crate feature process-node only.
Expand description

Registration information for a VPP process node

Used for registering and unregistering process nodes with VPP.

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

Implementations§

Source§

impl<N: ProcessNode, const N_NEXT_NODES: usize> ProcessNodeRegistration<N, N_NEXT_NODES>

Source

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

Creates a new ProcessNodeRegistration 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.
  • n_errors must match the discriminants in N::Errors
  • n_next_nodes must match the discriminants in N::NextNodes
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 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

Trait Implementations§

Source§

impl<N: ProcessNode, const N_NEXT_NODES: usize> Send for ProcessNodeRegistration<N, N_NEXT_NODES>

Source§

impl<N: ProcessNode, const N_NEXT_NODES: usize> Sync for ProcessNodeRegistration<N, N_NEXT_NODES>

Auto Trait Implementations§

§

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

§

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

§

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

§

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

§

impl<N, const N_NEXT_NODES: usize> UnwindSafe for ProcessNodeRegistration<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.