LCOV - code coverage report
Current view: top level - src/macho/commands - rpath.rs (source / functions) Coverage Total Hit
Test: lief.lcov Lines: 100.0 % 19 19
Test Date: 2024-11-30: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              : 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              : 
      22              : impl std::fmt::Debug for RPath<'_> {
      23           30 :     fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
      24           30 :         let base = self as &dyn Command;
      25           30 :         f.debug_struct("RPath")
      26           30 :             .field("base", &base)
      27           30 :             .field("path", &self.path())
      28           30 :             .finish()
      29           30 :     }
      30              : }
      31              : 
      32              : impl FromFFI<ffi::MachO_RPathCommand> for RPath<'_> {
      33           30 :     fn from_ffi(cmd: cxx::UniquePtr<ffi::MachO_RPathCommand>) -> Self {
      34           30 :         Self {
      35           30 :             ptr: cmd,
      36           30 :             _owner: PhantomData
      37           30 :         }
      38           30 :     }
      39              : }
      40              : 
      41              : impl Command for RPath<'_> {
      42          120 :     fn get_base(&self) -> &ffi::MachO_Command {
      43          120 :         self.ptr.as_ref().unwrap().as_ref()
      44          120 :     }
      45              : }
      46              : 
        

Generated by: LCOV version 2.1-1