LCOV - code coverage report
Current view: top level - src/macho/commands - two_level_hints.rs (source / functions) Coverage Total Hit
Test: lief.lcov Lines: 100.0 % 25 25
Test Date: 2024-11-30:00:00:00 Functions: 100.0 % 6 6

            Line data    Source code
       1              : use super::Command;
       2              : use lief_ffi as ffi;
       3              : use crate::common::FromFFI;
       4              : use crate::to_slice;
       5              : 
       6              : use std::marker::PhantomData;
       7              : 
       8              : /// Structure which represents the `LC_TWOLEVEL_HINTS` command
       9              : pub struct TwoLevelHints<'a> {
      10              :     ptr: cxx::UniquePtr<ffi::MachO_TwoLevelHints>,
      11              :     _owner: PhantomData<&'a ffi::MachO_Binary>
      12              : }
      13              : 
      14              : impl TwoLevelHints<'_> {
      15              :     /// Offset of the command. It should point in the `__LINKEDIT` segment
      16           20 :     pub fn offset(&self) -> u32 {
      17           20 :         self.ptr.offset()
      18           20 :     }
      19           10 :     pub fn original_nb_hints(&self) -> u32 {
      20           10 :         self.ptr.original_nb_hints()
      21           10 :     }
      22              : 
      23              :     /// Original payload of the command
      24           10 :     pub fn content(&self) -> &[u8] {
      25           10 :         to_slice!(self.ptr.content());
      26           10 :     }
      27              : }
      28              : 
      29              : impl std::fmt::Debug for TwoLevelHints<'_> {
      30           20 :     fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
      31           20 :         let base = self as &dyn Command;
      32           20 :         f.debug_struct("TwoLevelHints")
      33           20 :             .field("base", &base)
      34           20 :             .field("offset", &self.offset())
      35           20 :             .finish()
      36           20 :     }
      37              : }
      38              : 
      39              : impl FromFFI<ffi::MachO_TwoLevelHints> for TwoLevelHints<'_> {
      40           20 :     fn from_ffi(cmd: cxx::UniquePtr<ffi::MachO_TwoLevelHints>) -> Self {
      41           20 :         Self {
      42           20 :             ptr: cmd,
      43           20 :             _owner: PhantomData
      44           20 :         }
      45           20 :     }
      46              : }
      47              : 
      48              : impl Command for TwoLevelHints<'_> {
      49           80 :     fn get_base(&self) -> &ffi::MachO_Command {
      50           80 :         self.ptr.as_ref().unwrap().as_ref()
      51           80 :     }
      52              : }
      53              : 
        

Generated by: LCOV version 2.1-1