Skip to main content

vlib_process_node

Attribute Macro vlib_process_node 

Source
#[vlib_process_node]
Available on crate feature process-node only.
Expand description

Registers a VPP async process node

Creates a process node that runs an async coroutine, integrated with VPP’s event-driven processing model.

§Attributes

  • name: (required, string literal) The name of the process node
  • instance: (required, ident) The instance of the node.
  • runtime_data_default: (optional, ident) An identifier for a constant value of type Node::RuntimeData to use as the default runtime data for this node.
  • log2_stack_bytes: (optional, integer literal) Log2 of process stack size in bytes. Defaults to 0. The value will be set to a minimum value by VPP if smaller.

§Examples

static EXAMPLE_PROCESS_NODE: ExampleProcessNode = ExampleProcessNode::new();

#[vlib_process_node(
    name = "example-process",
    instance = EXAMPLE_PROCESS_NODE,
)]
struct ExampleProcessNode;

impl ExampleProcessNode {
    const fn new() -> Self {
        Self
    }
}

impl vlib::ProcessNode for ExampleProcessNode {
    type NextNodes = ExampleProcessNextNode;
    type RuntimeData = ();
    type Errors = ExampleProcessErrorCounter;

    async fn function(&self, vm: &mut vlib::MainRef, node: &mut vlib::NodeRuntimeRef<Self>) {
        todo!()
    }
}