LCOV - code coverage report
Current view: top level - src/macho/commands - rpath.rs (source / functions) Coverage Total Hit
Test: lief.lcov Lines: 86.4 % 22 19
Test Date: 2025-01-11:00:00:00 Functions: 80.0 % 5 4

            Line data    Source code
       1              : use super::Command;
       2              : use lief_ffi as ffi;
       3              : use crate::common::FromFFI;
       4              : use std::marker::PhantomData;
       5              : 
       6              : /// Structure that represents the `LC_RPATH` command.
       7              : ///
       8              : /// This command is used to add path for searching libraries
       9              : /// associated with the `@rpath` prefix.
      10              : pub struct RPath<'a> {
      11              :     ptr: cxx::UniquePtr<ffi::MachO_RPathCommand>,
      12              :     _owner: PhantomData<&'a ffi::MachO_Binary>
      13              : }
      14              : 
      15              : impl RPath<'_> {
      16              :     /// The rpath value as a string
      17           30 :     pub fn path(&self) -> String {
      18           30 :         self.ptr.path().to_string()
      19           30 :     }
      20              : 
      21              :     /// Original string offset of the path
      22            0 :     pub fn path_offset(&self) -> u32 {
      23            0 :         self.ptr.path_offset()
      24            0 :     }
      25              : }
      26              : 
      27              : impl std::fmt::Debug for RPath<'_> {
      28           30 :     fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
      29           30 :         let base = self as &dyn Command;
      30           30 :         f.debug_struct("RPath")
      31           30 :             .field("base", &base)
      32           30 :             .field("path", &self.path())
      33           30 :             .finish()
      34           30 :     }
      35              : }
      36              : 
      37              : impl FromFFI<ffi::MachO_RPathCommand> for RPath<'_> {
      38           30 :     fn from_ffi(cmd: cxx::UniquePtr<ffi::MachO_RPathCommand>) -> Self {
      39           30 :         Self {
      40           30 :             ptr: cmd,
      41           30 :             _owner: PhantomData
      42           30 :         }
      43           30 :     }
      44              : }
      45              : 
      46              : impl Command for RPath<'_> {
      47          120 :     fn get_base(&self) -> &ffi::MachO_Command {
      48          120 :         self.ptr.as_ref().unwrap().as_ref()
      49          120 :     }
      50              : }
      51              : 
        

Generated by: LCOV version 2.1-1