Skip to main content

apple_log/
os_log_entry_activity.rs

1use core::ffi::c_void;
2use std::ptr::NonNull;
3
4use crate::ffi;
5use crate::os_log_store::{OSLogEntryCommon, OSLogEntryFromProcess};
6
7/// Snapshot of an `OSLogEntryActivity` returned from `OSLogStore`.
8pub struct OSLogEntryActivity {
9    ptr: NonNull<c_void>,
10}
11
12impl OSLogEntryActivity {
13    pub(crate) const fn from_raw(ptr: NonNull<c_void>) -> Self {
14        Self { ptr }
15    }
16
17    #[must_use]
18    pub fn parent_activity_identifier(&self) -> u64 {
19        unsafe { ffi::apple_log_os_log_entry_parent_activity_identifier(self.ptr.as_ptr()) }
20    }
21}
22
23impl OSLogEntryCommon for OSLogEntryActivity {
24    fn raw_entry_ptr(&self) -> *mut c_void {
25        self.ptr.as_ptr()
26    }
27}
28
29impl OSLogEntryFromProcess for OSLogEntryActivity {}
30
31impl Drop for OSLogEntryActivity {
32    fn drop(&mut self) {
33        unsafe { ffi::apple_log_os_log_entry_release(self.ptr.as_ptr()) };
34    }
35}