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-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              : 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           24 :     pub fn path(&self) -> String {
      18           24 :         self.ptr.path().to_string()
      19           24 :     }
      20              : }
      21              : 
      22              : impl std::fmt::Debug for RPath<'_> {
      23           24 :     fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
      24           24 :         let base = self as &dyn Command;
      25           24 :         f.debug_struct("RPath")
      26           24 :             .field("base", &base)
      27           24 :             .field("path", &self.path())
      28           24 :             .finish()
      29           24 :     }
      30              : }
      31              : 
      32              : impl FromFFI<ffi::MachO_RPathCommand> for RPath<'_> {
      33           24 :     fn from_ffi(cmd: cxx::UniquePtr<ffi::MachO_RPathCommand>) -> Self {
      34           24 :         Self {
      35           24 :             ptr: cmd,
      36           24 :             _owner: PhantomData
      37           24 :         }
      38           24 :     }
      39              : }
      40              : 
      41              : impl Command for RPath<'_> {
      42           96 :     fn get_base(&self) -> &ffi::MachO_Command {
      43           96 :         self.ptr.as_ref().unwrap().as_ref()
      44           96 :     }
      45              : }
      46              : 
        

Generated by: LCOV version 2.1-1