Line data Source code
1 : use super::Command;
2 : use crate::common::FromFFI;
3 : use lief_ffi as ffi;
4 :
5 : use std::marker::PhantomData;
6 :
7 : /// Structure that represents the `LC_UUID` command
8 : pub struct UUID<'a> {
9 : ptr: cxx::UniquePtr<ffi::MachO_UUIDCommand>,
10 : _owner: PhantomData<&'a ffi::MachO_Binary>,
11 : }
12 :
13 : impl UUID<'_> {
14 : /// The UUID as a 16-bytes array
15 806 : pub fn uuid(&self) -> Vec<u64> {
16 806 : Vec::from(self.ptr.uuid().as_slice())
17 806 : }
18 : }
19 :
20 : impl std::fmt::Debug for UUID<'_> {
21 806 : fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
22 806 : let base = self as &dyn Command;
23 806 : f.debug_struct("UUID")
24 806 : .field("base", &base)
25 806 : .field("uuid", &self.uuid())
26 806 : .finish()
27 806 : }
28 : }
29 :
30 : impl FromFFI<ffi::MachO_UUIDCommand> for UUID<'_> {
31 806 : fn from_ffi(cmd: cxx::UniquePtr<ffi::MachO_UUIDCommand>) -> Self {
32 806 : Self {
33 806 : ptr: cmd,
34 806 : _owner: PhantomData,
35 806 : }
36 806 : }
37 : }
38 :
39 : impl Command for UUID<'_> {
40 3224 : fn get_base(&self) -> &ffi::MachO_Command {
41 3224 : self.ptr.as_ref().unwrap().as_ref()
42 3224 : }
43 : }
|