Struct solana_rbpf::ebpf::Insn

source ·
pub struct Insn {
    pub ptr: usize,
    pub opc: u8,
    pub dst: u8,
    pub src: u8,
    pub off: i16,
    pub imm: i64,
}
Expand description

An eBPF instruction.

See https://www.kernel.org/doc/Documentation/networking/filter.txt for the Linux kernel documentation about eBPF, or https://github.com/iovisor/bpf-docs/blob/master/eBPF.md for a more concise version.

Fields§

§ptr: usize

Instruction pointer.

§opc: u8

Operation code.

§dst: u8

Destination register operand.

§src: u8

Source register operand.

§off: i16

Offset operand.

§imm: i64

Immediate value operand.

Implementations§

source§

impl Insn

source

pub fn to_array(&self) -> [u8; 8]

Turn an Insn back into an array of bytes.

§Examples
use solana_rbpf::ebpf;

let prog: &[u8] = &[
    0xb7, 0x12, 0x56, 0x34, 0xde, 0xbc, 0x9a, 0x78,
    ];
let insn = ebpf::Insn {
    ptr: 0x00,
    opc: 0xb7,
    dst: 2,
    src: 1,
    off: 0x3456,
    imm: 0x789abcde
};
assert_eq!(insn.to_array(), prog);
source

pub fn to_vec(&self) -> Vec<u8>

Turn an Insn into an vector of bytes.

§Examples
use solana_rbpf::ebpf;

let prog: Vec<u8> = vec![
    0xb7, 0x12, 0x56, 0x34, 0xde, 0xbc, 0x9a, 0x78,
    ];
let insn = ebpf::Insn {
    ptr: 0x00,
    opc: 0xb7,
    dst: 2,
    src: 1,
    off: 0x3456,
    imm: 0x789abcde
};
assert_eq!(insn.to_vec(), prog);

Trait Implementations§

source§

impl Clone for Insn

source§

fn clone(&self) -> Insn

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl Debug for Insn

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl Default for Insn

source§

fn default() -> Insn

Returns the “default value” for a type. Read more
source§

impl PartialEq for Insn

source§

fn eq(&self, other: &Insn) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl Eq for Insn

source§

impl StructuralPartialEq for Insn

Auto Trait Implementations§

§

impl Freeze for Insn

§

impl RefUnwindSafe for Insn

§

impl Send for Insn

§

impl Sync for Insn

§

impl Unpin for Insn

§

impl UnwindSafe for Insn

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> IntoEither for T

source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
source§

impl<T> ToOwned for T
where T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

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>,

§

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.
source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

source§

fn vzip(self) -> V