LCOV - code coverage report
Current view: top level - src/macho/commands - unknown.rs (source / functions) Coverage Total Hit
Test: lief.lcov Lines: 100.0 % 19 19
Test Date: 2024-10-27:00:00:00 Functions: 100.0 % 4 4

            Line data    Source code
       1              : use super::Command;
       2              : use lief_ffi as ffi;
       3              : use crate::common::FromFFI;
       4              : 
       5              : use std::marker::PhantomData;
       6              : 
       7              : /// Generic structure when the command is not recognized by LIEF (e.g private `LC_xxx` command)
       8              : pub struct Unknown<'a> {
       9              :     ptr: cxx::UniquePtr<ffi::MachO_UnknownCommand>,
      10              :     _owner: PhantomData<&'a ffi::MachO_Binary>
      11              : }
      12              : 
      13              : 
      14              : impl Unknown<'_> {
      15              :     /// The original `LC_` int that is not supported by LIEF
      16           64 :     pub fn original_command(&self) -> u64 {
      17           64 :         self.ptr.original_command()
      18           64 :     }
      19              : }
      20              : 
      21              : impl std::fmt::Debug for Unknown<'_> {
      22           32 :     fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
      23           32 :         let base = self as &dyn Command;
      24           32 :         f.debug_struct("UnknownCommand")
      25           32 :             .field("base", &base)
      26           32 :             .field("original_command", &self.original_command())
      27           32 :             .finish()
      28           32 :     }
      29              : }
      30              : 
      31              : impl FromFFI<ffi::MachO_UnknownCommand> for Unknown<'_> {
      32           32 :     fn from_ffi(cmd: cxx::UniquePtr<ffi::MachO_UnknownCommand>) -> Self {
      33           32 :         Self {
      34           32 :             ptr: cmd,
      35           32 :             _owner: PhantomData
      36           32 :         }
      37           32 :     }
      38              : }
      39              : 
      40              : impl Command for Unknown<'_> {
      41          128 :     fn get_base(&self) -> &ffi::MachO_Command {
      42          128 :         self.ptr.as_ref().unwrap().as_ref()
      43          128 :     }
      44              : }
        

Generated by: LCOV version 2.1-1