Line data Source code
1 : use lief_ffi as ffi;
2 :
3 : use super::Opcode;
4 : use crate::assembly;
5 : use crate::common::FromFFI;
6 :
7 : /// This structure represents an eBPF instruction
8 : pub struct Instruction {
9 : ptr: cxx::UniquePtr<ffi::asm_ebpf_Instruction>,
10 : }
11 :
12 : impl FromFFI<ffi::asm_ebpf_Instruction> for Instruction {
13 0 : fn from_ffi(ptr: cxx::UniquePtr<ffi::asm_ebpf_Instruction>) -> Self {
14 0 : Self { ptr }
15 0 : }
16 : }
17 :
18 : impl assembly::Instruction for Instruction {
19 : #[doc(hidden)]
20 0 : fn as_generic(&self) -> &ffi::asm_Instruction {
21 0 : self.ptr.as_ref().unwrap().as_ref()
22 0 : }
23 : }
24 :
25 : impl Instruction {
26 : /// The instruction opcode as defined in LLVM
27 0 : pub fn opcode(&self) -> Opcode {
28 0 : Opcode::from(self.ptr.opcode())
29 0 : }
30 : }
|