[][src]Struct solana_rbpf::ebpf::Insn

pub struct Insn {
    pub opc: u8,
    pub dst: u8,
    pub src: u8,
    pub off: i16,
    pub imm: i32,
}

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

opc: u8

Operation code.

dst: u8

Destination register operand.

src: u8

Source register operand.

off: i16

Offset operand.

imm: i32

Immediate value operand.

Methods

impl Insn[src]

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

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 {
    opc: 0xb7,
    dst: 2,
    src: 1,
    off: 0x3456,
    imm: 0x789abcde
};
assert_eq!(insn.to_array(), prog);

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

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 {
    opc: 0xb7,
    dst: 2,
    src: 1,
    off: 0x3456,
    imm: 0x789abcde
};
assert_eq!(insn.to_vec(), prog);

Trait Implementations

impl Clone for Insn[src]

impl Debug for Insn[src]

impl PartialEq<Insn> for Insn[src]

impl StructuralPartialEq for Insn[src]

Auto Trait Implementations

impl RefUnwindSafe for Insn

impl Send for Insn

impl Sync for Insn

impl Unpin for Insn

impl UnwindSafe for Insn

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.