ProgramArgument

Trait ProgramArgument 

Source
pub trait ProgramArgument: Into<BpfValue> {
    // Required method
    fn get_type() -> &'static Type;

    // Provided methods
    fn get_value_type(&self) -> Type { ... }
    fn field_mappings() -> &'static [FieldMapping] { ... }
    fn struct_mapping() -> Option<StructMapping> { ... }
}
Expand description

Trait that should be implemented for arguments passed to eBPF programs.

Required Methods§

Source

fn get_type() -> &'static Type

Returns eBPF type that corresponds to Self. Used when program argument types are checked statically.

Provided Methods§

Source

fn get_value_type(&self) -> Type

Returns eBPF type for a specific value of Self. For most types this is the same type that’s returned by get_type(), but that’s not always the case. In particular for scalar values this will return Type::ScalarValue with the actual value of the scalar and with unknown_mask = 0.

Source

fn field_mappings() -> &'static [FieldMapping]

Returns the list of field mappings that should be applied with this argument. If not empty then get_type() must be a PtrToStruct.

Source

fn struct_mapping() -> Option<StructMapping>

Returns the StructMapping that should be applied with this argument. Implementations should override field_mappings() and keep default implementation of struct_mapping().

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementations on Foreign Types§

Source§

impl ProgramArgument for ()

Source§

fn get_type() -> &'static Type

Source§

impl ProgramArgument for usize

Source§

fn get_type() -> &'static Type

Source§

fn get_value_type(&self) -> Type

Implementors§