Skip to main content

apple_log/
os_log_entry_boundary.rs

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