[][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 PartialEq<Insn> for Insn
[src]

impl Clone for Insn
[src]

fn clone_from(&mut self, source: &Self)
1.0.0
[src]

Performs copy-assignment from source. Read more

impl Debug for Insn
[src]

Auto Trait Implementations

impl Send for Insn

impl Sync for Insn

Blanket Implementations

impl<T> From for T
[src]

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

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

type Owned = T

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

type Error = !

🔬 This is a nightly-only experimental API. (try_from)

The type returned in the event of a conversion error.

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

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

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

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

🔬 This is a nightly-only experimental API. (try_from)

The type returned in the event of a conversion error.

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