objc2_os_log/generated/
mod.rs

1// This file has been automatically generated by `objc2`'s `header-translator`.
2// DO NOT EDIT
3
4#![allow(unused_imports)]
5#![allow(deprecated)]
6#![allow(non_snake_case)]
7#![allow(non_camel_case_types)]
8#![allow(non_upper_case_globals)]
9#![allow(missing_docs)]
10#![allow(clippy::too_many_arguments)]
11#![allow(clippy::type_complexity)]
12#![allow(clippy::upper_case_acronyms)]
13#![allow(clippy::identity_op)]
14#![allow(clippy::missing_safety_doc)]
15#![allow(clippy::doc_lazy_continuation)]
16#![allow(rustdoc::broken_intra_doc_links)]
17#![allow(rustdoc::bare_urls)]
18#![allow(rustdoc::invalid_html_tags)]
19
20#[link(name = "OSLog", kind = "framework")]
21extern "C" {}
22
23use core::ffi::*;
24use core::ptr::NonNull;
25use objc2::__framework_prelude::*;
26use objc2_foundation::*;
27
28use crate::*;
29
30/// A classification of how the entry was to be stored and
31/// rotated at the point when it was created.
32///
33///
34/// The unified logging system keeps entries in one of two
35/// places: a ring buffer in memory and a persisted data store.
36/// Entries are rotated out of both places to free up resources.
37/// This rotation is not strictly aligned with entries'
38/// timestamps --- in particular, they can be rotated in bulk,
39/// and they are rotated according to a series of heuristics that
40/// take into account space, time, and how the entries were
41/// classified.
42///
43///
44/// This entry was generated as information about the other
45/// entries or about the sequence of entries as a whole.
46///
47///
48/// This entry was not intended to be long-lived and was captured
49/// in the ring buffer.
50///
51///
52/// The entry was intended to be persisted in a filesystem-backed
53/// data store and kept mainly based on the amount of space
54/// available.
55///
56///
57///
58///
59///
60///
61/// The entry was tagged with a hint indicating that the system
62/// should try to preserve it for a certain amount of time. It
63/// was persisted in the filesystem-backed data store, and
64/// rotation of these entries was based on both time and space
65/// considerations.
66///
67/// See also [Apple's documentation](https://developer.apple.com/documentation/oslog/oslogentrystorecategory?language=objc)
68// NS_ENUM
69#[repr(transparent)]
70#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
71pub struct OSLogEntryStoreCategory(pub NSInteger);
72impl OSLogEntryStoreCategory {
73    #[doc(alias = "OSLogEntryStoreCategoryUndefined")]
74    pub const Undefined: Self = Self(0);
75    #[doc(alias = "OSLogEntryStoreCategoryMetadata")]
76    pub const Metadata: Self = Self(1);
77    #[doc(alias = "OSLogEntryStoreCategoryShortTerm")]
78    pub const ShortTerm: Self = Self(2);
79    #[doc(alias = "OSLogEntryStoreCategoryLongTermAuto")]
80    pub const LongTermAuto: Self = Self(3);
81    #[doc(alias = "OSLogEntryStoreCategoryLongTerm1")]
82    pub const LongTerm1: Self = Self(4);
83    #[doc(alias = "OSLogEntryStoreCategoryLongTerm3")]
84    pub const LongTerm3: Self = Self(5);
85    #[doc(alias = "OSLogEntryStoreCategoryLongTerm7")]
86    pub const LongTerm7: Self = Self(6);
87    #[doc(alias = "OSLogEntryStoreCategoryLongTerm14")]
88    pub const LongTerm14: Self = Self(7);
89    #[doc(alias = "OSLogEntryStoreCategoryLongTerm30")]
90    pub const LongTerm30: Self = Self(8);
91}
92
93unsafe impl Encode for OSLogEntryStoreCategory {
94    const ENCODING: Encoding = NSInteger::ENCODING;
95}
96
97unsafe impl RefEncode for OSLogEntryStoreCategory {
98    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
99}
100
101extern_class!(
102    /// A single entry from the unified logging system.
103    ///
104    /// See also [Apple's documentation](https://developer.apple.com/documentation/oslog/oslogentry?language=objc)
105    #[unsafe(super(NSObject))]
106    #[derive(Debug, PartialEq, Eq, Hash)]
107    pub struct OSLogEntry;
108);
109
110extern_conformance!(
111    unsafe impl NSObjectProtocol for OSLogEntry {}
112);
113
114impl OSLogEntry {
115    extern_methods!(
116        /// The fully formatted message for the entry.
117        #[unsafe(method(composedMessage))]
118        #[unsafe(method_family = none)]
119        pub unsafe fn composedMessage(&self) -> Retained<NSString>;
120
121        /// The timestamp of the entry.
122        #[unsafe(method(date))]
123        #[unsafe(method_family = none)]
124        pub unsafe fn date(&self) -> Retained<NSDate>;
125
126        /// This entry's storage tag. See OSLogEntryStoreCategory.
127        #[unsafe(method(storeCategory))]
128        #[unsafe(method_family = none)]
129        pub unsafe fn storeCategory(&self) -> OSLogEntryStoreCategory;
130    );
131}
132
133/// Methods declared on superclass `NSObject`.
134impl OSLogEntry {
135    extern_methods!(
136        #[unsafe(method(init))]
137        #[unsafe(method_family = init)]
138        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
139
140        #[unsafe(method(new))]
141        #[unsafe(method_family = new)]
142        pub unsafe fn new() -> Retained<Self>;
143    );
144}
145
146extern_protocol!(
147    /// Entry subclasses conforming to this protocol represent data
148    /// that are generated from a process; they have metadata about
149    /// the originator.
150    ///
151    /// See also [Apple's documentation](https://developer.apple.com/documentation/oslog/oslogentryfromprocess?language=objc)
152    pub unsafe trait OSLogEntryFromProcess {
153        /// The activity ID associated with the entry.
154        #[unsafe(method(activityIdentifier))]
155        #[unsafe(method_family = none)]
156        unsafe fn activityIdentifier(&self) -> os_activity_id_t;
157
158        /// The name of the process that made the entry.
159        #[unsafe(method(process))]
160        #[unsafe(method_family = none)]
161        unsafe fn process(&self) -> Retained<NSString>;
162
163        #[cfg(feature = "libc")]
164        /// The pid of the process that made the entry.
165        #[unsafe(method(processIdentifier))]
166        #[unsafe(method_family = none)]
167        unsafe fn processIdentifier(&self) -> libc::pid_t;
168
169        /// The name of the binary image that made the entry.
170        #[unsafe(method(sender))]
171        #[unsafe(method_family = none)]
172        unsafe fn sender(&self) -> Retained<NSString>;
173
174        /// The tid of the thread that made the entry.
175        #[unsafe(method(threadIdentifier))]
176        #[unsafe(method_family = none)]
177        unsafe fn threadIdentifier(&self) -> u64;
178    }
179);
180
181extern_protocol!(
182    /// Entry subclasses conforming to this protocol represent
183    /// entries that were made using a handle and a format string.
184    ///
185    /// See also [Apple's documentation](https://developer.apple.com/documentation/oslog/oslogentrywithpayload?language=objc)
186    pub unsafe trait OSLogEntryWithPayload {
187        /// The category from the os_log_t handle used.
188        #[unsafe(method(category))]
189        #[unsafe(method_family = none)]
190        unsafe fn category(&self) -> Retained<NSString>;
191
192        /// An array of the various parts of the composed message.
193        #[unsafe(method(components))]
194        #[unsafe(method_family = none)]
195        unsafe fn components(&self) -> Retained<NSArray<OSLogMessageComponent>>;
196
197        /// The format string used.
198        #[unsafe(method(formatString))]
199        #[unsafe(method_family = none)]
200        unsafe fn formatString(&self) -> Retained<NSString>;
201
202        /// The subsystem of the os_log_t handle used.
203        #[unsafe(method(subsystem))]
204        #[unsafe(method_family = none)]
205        unsafe fn subsystem(&self) -> Retained<NSString>;
206    }
207);
208
209impl OSLogEntry {
210    extern_methods!();
211}
212
213extern_conformance!(
214    unsafe impl NSSecureCoding for OSLogEntry {}
215);
216
217extern_class!(
218    /// An entry generated by an activity event.
219    ///
220    /// See also [Apple's documentation](https://developer.apple.com/documentation/oslog/oslogentryactivity?language=objc)
221    #[unsafe(super(OSLogEntry, NSObject))]
222    #[derive(Debug, PartialEq, Eq, Hash)]
223    pub struct OSLogEntryActivity;
224);
225
226extern_conformance!(
227    unsafe impl NSObjectProtocol for OSLogEntryActivity {}
228);
229
230extern_conformance!(
231    unsafe impl OSLogEntryFromProcess for OSLogEntryActivity {}
232);
233
234impl OSLogEntryActivity {
235    extern_methods!(
236        /// This parent activity's activity ID.
237        #[unsafe(method(parentActivityIdentifier))]
238        #[unsafe(method_family = none)]
239        pub unsafe fn parentActivityIdentifier(&self) -> os_activity_id_t;
240    );
241}
242
243/// Methods declared on superclass `NSObject`.
244impl OSLogEntryActivity {
245    extern_methods!(
246        #[unsafe(method(init))]
247        #[unsafe(method_family = init)]
248        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
249
250        #[unsafe(method(new))]
251        #[unsafe(method_family = new)]
252        pub unsafe fn new() -> Retained<Self>;
253    );
254}
255
256extern_class!(
257    /// This entry represents metadata that partitions sequences of
258    /// other entries.
259    ///
260    ///
261    /// For example, this kind of entry is used for boot boundaries.
262    /// The data here are currently informational and carried in the
263    /// composedMessage property.
264    ///
265    /// See also [Apple's documentation](https://developer.apple.com/documentation/oslog/oslogentryboundary?language=objc)
266    #[unsafe(super(OSLogEntry, NSObject))]
267    #[derive(Debug, PartialEq, Eq, Hash)]
268    pub struct OSLogEntryBoundary;
269);
270
271extern_conformance!(
272    unsafe impl NSObjectProtocol for OSLogEntryBoundary {}
273);
274
275impl OSLogEntryBoundary {
276    extern_methods!();
277}
278
279/// Methods declared on superclass `NSObject`.
280impl OSLogEntryBoundary {
281    extern_methods!(
282        #[unsafe(method(init))]
283        #[unsafe(method_family = init)]
284        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
285
286        #[unsafe(method(new))]
287        #[unsafe(method_family = new)]
288        pub unsafe fn new() -> Retained<Self>;
289    );
290}
291
292/// The level that this entry was generated at.
293///
294/// See also [Apple's documentation](https://developer.apple.com/documentation/oslog/oslogentryloglevel?language=objc)
295// NS_ENUM
296#[repr(transparent)]
297#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
298pub struct OSLogEntryLogLevel(pub NSInteger);
299impl OSLogEntryLogLevel {
300    #[doc(alias = "OSLogEntryLogLevelUndefined")]
301    pub const Undefined: Self = Self(0);
302    #[doc(alias = "OSLogEntryLogLevelDebug")]
303    pub const Debug: Self = Self(1);
304    #[doc(alias = "OSLogEntryLogLevelInfo")]
305    pub const Info: Self = Self(2);
306    #[doc(alias = "OSLogEntryLogLevelNotice")]
307    pub const Notice: Self = Self(3);
308    #[doc(alias = "OSLogEntryLogLevelError")]
309    pub const Error: Self = Self(4);
310    #[doc(alias = "OSLogEntryLogLevelFault")]
311    pub const Fault: Self = Self(5);
312}
313
314unsafe impl Encode for OSLogEntryLogLevel {
315    const ENCODING: Encoding = NSInteger::ENCODING;
316}
317
318unsafe impl RefEncode for OSLogEntryLogLevel {
319    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
320}
321
322extern_class!(
323    /// Entries made by the os_log API.
324    ///
325    /// See also [Apple's documentation](https://developer.apple.com/documentation/oslog/oslogentrylog?language=objc)
326    #[unsafe(super(OSLogEntry, NSObject))]
327    #[derive(Debug, PartialEq, Eq, Hash)]
328    pub struct OSLogEntryLog;
329);
330
331extern_conformance!(
332    unsafe impl NSObjectProtocol for OSLogEntryLog {}
333);
334
335extern_conformance!(
336    unsafe impl OSLogEntryFromProcess for OSLogEntryLog {}
337);
338
339extern_conformance!(
340    unsafe impl OSLogEntryWithPayload for OSLogEntryLog {}
341);
342
343impl OSLogEntryLog {
344    extern_methods!(
345        /// The level of the entry, e.g., info, debug.
346        #[unsafe(method(level))]
347        #[unsafe(method_family = none)]
348        pub unsafe fn level(&self) -> OSLogEntryLogLevel;
349    );
350}
351
352/// Methods declared on superclass `NSObject`.
353impl OSLogEntryLog {
354    extern_methods!(
355        #[unsafe(method(init))]
356        #[unsafe(method_family = init)]
357        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
358
359        #[unsafe(method(new))]
360        #[unsafe(method_family = new)]
361        pub unsafe fn new() -> Retained<Self>;
362    );
363}
364
365/// The kind of of signpost emitted.
366///
367/// See also [Apple's documentation](https://developer.apple.com/documentation/oslog/oslogentrysignposttype?language=objc)
368// NS_ENUM
369#[repr(transparent)]
370#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
371pub struct OSLogEntrySignpostType(pub NSInteger);
372impl OSLogEntrySignpostType {
373    #[doc(alias = "OSLogEntrySignpostTypeUndefined")]
374    pub const Undefined: Self = Self(0);
375    #[doc(alias = "OSLogEntrySignpostTypeIntervalBegin")]
376    pub const IntervalBegin: Self = Self(1);
377    #[doc(alias = "OSLogEntrySignpostTypeIntervalEnd")]
378    pub const IntervalEnd: Self = Self(2);
379    #[doc(alias = "OSLogEntrySignpostTypeEvent")]
380    pub const Event: Self = Self(3);
381}
382
383unsafe impl Encode for OSLogEntrySignpostType {
384    const ENCODING: Encoding = NSInteger::ENCODING;
385}
386
387unsafe impl RefEncode for OSLogEntrySignpostType {
388    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
389}
390
391extern_class!(
392    /// Entries made by the os_signpost API.
393    ///
394    /// See also [Apple's documentation](https://developer.apple.com/documentation/oslog/oslogentrysignpost?language=objc)
395    #[unsafe(super(OSLogEntry, NSObject))]
396    #[derive(Debug, PartialEq, Eq, Hash)]
397    pub struct OSLogEntrySignpost;
398);
399
400extern_conformance!(
401    unsafe impl NSObjectProtocol for OSLogEntrySignpost {}
402);
403
404extern_conformance!(
405    unsafe impl OSLogEntryFromProcess for OSLogEntrySignpost {}
406);
407
408extern_conformance!(
409    unsafe impl OSLogEntryWithPayload for OSLogEntrySignpost {}
410);
411
412impl OSLogEntrySignpost {
413    extern_methods!(
414        /// The signpost ID associated with this entry.
415        #[unsafe(method(signpostIdentifier))]
416        #[unsafe(method_family = none)]
417        pub unsafe fn signpostIdentifier(&self) -> os_signpost_id_t;
418
419        /// The signpost name associated with this entry.
420        #[unsafe(method(signpostName))]
421        #[unsafe(method_family = none)]
422        pub unsafe fn signpostName(&self) -> Retained<NSString>;
423
424        /// The signpost type associated with this entry.
425        #[unsafe(method(signpostType))]
426        #[unsafe(method_family = none)]
427        pub unsafe fn signpostType(&self) -> OSLogEntrySignpostType;
428    );
429}
430
431/// Methods declared on superclass `NSObject`.
432impl OSLogEntrySignpost {
433    extern_methods!(
434        #[unsafe(method(init))]
435        #[unsafe(method_family = init)]
436        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
437
438        #[unsafe(method(new))]
439        #[unsafe(method_family = new)]
440        pub unsafe fn new() -> Retained<Self>;
441    );
442}
443
444/// Control the direction of the iteration.
445///
446///
447/// Iterate backward in time. If no starting position is specified,
448/// start at the latest entry.
449///
450/// See also [Apple's documentation](https://developer.apple.com/documentation/oslog/oslogenumeratoroptions?language=objc)
451// NS_OPTIONS
452#[repr(transparent)]
453#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
454pub struct OSLogEnumeratorOptions(pub NSUInteger);
455bitflags::bitflags! {
456    impl OSLogEnumeratorOptions: NSUInteger {
457        #[doc(alias = "OSLogEnumeratorReverse")]
458        const Reverse = 0x01;
459    }
460}
461
462unsafe impl Encode for OSLogEnumeratorOptions {
463    const ENCODING: Encoding = NSUInteger::ENCODING;
464}
465
466unsafe impl RefEncode for OSLogEnumeratorOptions {
467    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
468}
469
470extern_class!(
471    /// An enumerator that views entries in the unified logging system.
472    ///
473    /// See also [Apple's documentation](https://developer.apple.com/documentation/oslog/oslogenumerator?language=objc)
474    #[unsafe(super(NSEnumerator, NSObject))]
475    #[derive(Debug, PartialEq, Eq, Hash)]
476    pub struct OSLogEnumerator;
477);
478
479extern_conformance!(
480    unsafe impl NSFastEnumeration for OSLogEnumerator {}
481);
482
483extern_conformance!(
484    unsafe impl NSObjectProtocol for OSLogEnumerator {}
485);
486
487impl OSLogEnumerator {
488    extern_methods!();
489}
490
491/// Methods declared on superclass `NSObject`.
492impl OSLogEnumerator {
493    extern_methods!(
494        #[unsafe(method(init))]
495        #[unsafe(method_family = init)]
496        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
497
498        #[unsafe(method(new))]
499        #[unsafe(method_family = new)]
500        pub unsafe fn new() -> Retained<Self>;
501    );
502}
503
504/// The kind of data corresponding to an argument in a message
505/// payload, like the number associated with a "%d" placeholder.
506/// This value can be undefined if the argument data cannot be
507/// decoded; for example, it may be redacted.
508///
509/// See also [Apple's documentation](https://developer.apple.com/documentation/oslog/oslogmessagecomponentargumentcategory?language=objc)
510// NS_ENUM
511#[repr(transparent)]
512#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
513pub struct OSLogMessageComponentArgumentCategory(pub NSInteger);
514impl OSLogMessageComponentArgumentCategory {
515    #[doc(alias = "OSLogMessageComponentArgumentCategoryUndefined")]
516    pub const Undefined: Self = Self(0);
517    #[doc(alias = "OSLogMessageComponentArgumentCategoryData")]
518    pub const Data: Self = Self(1);
519    #[doc(alias = "OSLogMessageComponentArgumentCategoryDouble")]
520    pub const Double: Self = Self(2);
521    #[doc(alias = "OSLogMessageComponentArgumentCategoryInt64")]
522    pub const Int64: Self = Self(3);
523    #[doc(alias = "OSLogMessageComponentArgumentCategoryString")]
524    pub const String: Self = Self(4);
525    #[doc(alias = "OSLogMessageComponentArgumentCategoryUInt64")]
526    pub const UInt64: Self = Self(5);
527}
528
529unsafe impl Encode for OSLogMessageComponentArgumentCategory {
530    const ENCODING: Encoding = NSInteger::ENCODING;
531}
532
533unsafe impl RefEncode for OSLogMessageComponentArgumentCategory {
534    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
535}
536
537extern_class!(
538    /// The message arguments for a particular entry. There is one
539    /// component for each placeholder in the formatString plus one
540    /// component for any text after the last placeholder.
541    ///
542    /// See also [Apple's documentation](https://developer.apple.com/documentation/oslog/oslogmessagecomponent?language=objc)
543    #[unsafe(super(NSObject))]
544    #[derive(Debug, PartialEq, Eq, Hash)]
545    pub struct OSLogMessageComponent;
546);
547
548extern_conformance!(
549    unsafe impl NSCoding for OSLogMessageComponent {}
550);
551
552extern_conformance!(
553    unsafe impl NSObjectProtocol for OSLogMessageComponent {}
554);
555
556extern_conformance!(
557    unsafe impl NSSecureCoding for OSLogMessageComponent {}
558);
559
560impl OSLogMessageComponent {
561    extern_methods!(
562        /// The text immediately preceding a placeholder. This can be an
563        /// empty string if there is nothing between two placeholders, or
564        /// between the placeholder and the bounds of the string.
565        #[unsafe(method(formatSubstring))]
566        #[unsafe(method_family = none)]
567        pub unsafe fn formatSubstring(&self) -> Retained<NSString>;
568
569        /// The placeholder text. Is empty for is the last component.
570        #[unsafe(method(placeholder))]
571        #[unsafe(method_family = none)]
572        pub unsafe fn placeholder(&self) -> Retained<NSString>;
573
574        /// The type of argument corresponding to the placeholder; see
575        /// OSLogMessageComponentArgumentCategory.
576        #[unsafe(method(argumentCategory))]
577        #[unsafe(method_family = none)]
578        pub unsafe fn argumentCategory(&self) -> OSLogMessageComponentArgumentCategory;
579
580        /// The argument as a sequence of bytes. Can be nil if the
581        /// argument cannot be decoded (for example, it could be
582        /// redacted), or if this is the last component.
583        #[unsafe(method(argumentDataValue))]
584        #[unsafe(method_family = none)]
585        pub unsafe fn argumentDataValue(&self) -> Option<Retained<NSData>>;
586
587        /// The argument as a double-precision floating point number; the
588        /// value is undefined if the argument cannot be decoded or if this
589        /// is the last component.
590        #[unsafe(method(argumentDoubleValue))]
591        #[unsafe(method_family = none)]
592        pub unsafe fn argumentDoubleValue(&self) -> c_double;
593
594        /// The argument as a 64-bit signed integer; the value is undefined
595        /// if it cannot be decoded or if this is the last component.
596        #[unsafe(method(argumentInt64Value))]
597        #[unsafe(method_family = none)]
598        pub unsafe fn argumentInt64Value(&self) -> i64;
599
600        /// The argument as a number. Can be nil if the argument cannot
601        /// be decoded (for example, it could be redacted), or if this is
602        /// the last component.
603        #[unsafe(method(argumentNumberValue))]
604        #[unsafe(method_family = none)]
605        pub unsafe fn argumentNumberValue(&self) -> Option<Retained<NSNumber>>;
606
607        /// The argument as a string. Can be nil if the argument cannot
608        /// be decoded (for example, it could be redacted), or if this is
609        /// the last component.
610        #[unsafe(method(argumentStringValue))]
611        #[unsafe(method_family = none)]
612        pub unsafe fn argumentStringValue(&self) -> Option<Retained<NSString>>;
613
614        /// The argument as a 64-bit unsigned integer; the value is
615        /// undefined if the argument cannot be decoded or if this is the
616        /// last component.
617        #[unsafe(method(argumentUInt64Value))]
618        #[unsafe(method_family = none)]
619        pub unsafe fn argumentUInt64Value(&self) -> u64;
620    );
621}
622
623/// Methods declared on superclass `NSObject`.
624impl OSLogMessageComponent {
625    extern_methods!(
626        #[unsafe(method(init))]
627        #[unsafe(method_family = init)]
628        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
629
630        #[unsafe(method(new))]
631        #[unsafe(method_family = new)]
632        pub unsafe fn new() -> Retained<Self>;
633    );
634}
635
636extern_class!(
637    /// An opaque abstraction representing a point in a sequence of
638    /// entries in the unified logging system.
639    ///
640    ///
641    /// Generate positions with OSLogStore instance methods and use them
642    /// to start viewing entries from a particular starting point.
643    ///
644    /// See also [Apple's documentation](https://developer.apple.com/documentation/oslog/oslogposition?language=objc)
645    #[unsafe(super(NSObject))]
646    #[derive(Debug, PartialEq, Eq, Hash)]
647    pub struct OSLogPosition;
648);
649
650extern_conformance!(
651    unsafe impl NSObjectProtocol for OSLogPosition {}
652);
653
654impl OSLogPosition {
655    extern_methods!(
656        #[unsafe(method(init))]
657        #[unsafe(method_family = init)]
658        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
659    );
660}
661
662/// Methods declared on superclass `NSObject`.
663impl OSLogPosition {
664    extern_methods!(
665        #[unsafe(method(new))]
666        #[unsafe(method_family = new)]
667        pub unsafe fn new() -> Retained<Self>;
668    );
669}
670
671/// Create a store to a subset of the libtrace entries.
672///
673///
674///
675/// "System" scope indicates the entire system; i.e., all logs. Entries can be
676/// retrieved for the current calling process, i.e., matching pid.
677///
678/// See also [Apple's documentation](https://developer.apple.com/documentation/oslog/oslogstorescope?language=objc)
679// NS_ENUM
680#[repr(transparent)]
681#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
682pub struct OSLogStoreScope(pub NSInteger);
683impl OSLogStoreScope {
684    #[doc(alias = "OSLogStoreSystem")]
685    pub const System: Self = Self(0);
686    #[doc(alias = "OSLogStoreCurrentProcessIdentifier")]
687    pub const CurrentProcessIdentifier: Self = Self(1);
688}
689
690unsafe impl Encode for OSLogStoreScope {
691    const ENCODING: Encoding = NSInteger::ENCODING;
692}
693
694unsafe impl RefEncode for OSLogStoreScope {
695    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
696}
697
698extern_class!(
699    /// A set of entries from the unified logging system. Instances
700    /// represent a fixed range of entries and may be backed by a
701    /// logarchive or the Mac's local store.
702    ///
703    ///
704    /// Entries in OSLogStore objects are used by OSLogEnumerator
705    /// instances; one store can support multiple OSLogEnumerator
706    /// instances concurrently.
707    ///
708    /// See also [Apple's documentation](https://developer.apple.com/documentation/oslog/oslogstore?language=objc)
709    #[unsafe(super(NSObject))]
710    #[derive(Debug, PartialEq, Eq, Hash)]
711    pub struct OSLogStore;
712);
713
714extern_conformance!(
715    unsafe impl NSObjectProtocol for OSLogStore {}
716);
717
718impl OSLogStore {
719    extern_methods!(
720        /// Create an OSLogStore representing the Mac's local store.
721        ///
722        ///
723        /// Parameter `error`: If initialization is unsuccessful --- for example, this process
724        /// does not have access to local logs --- return nil and set this
725        /// parameter to a pointer to an error object describing the reason.
726        ///
727        ///
728        /// This enables processing of a sequence of logs as of the particular
729        /// point in time when this object is created.
730        ///
731        /// Gaining access to the local unified logging system requires
732        /// permission from the system. The caller must be run by an admin
733        /// account.
734        #[unsafe(method(localStoreAndReturnError:_))]
735        #[unsafe(method_family = none)]
736        pub unsafe fn localStoreAndReturnError() -> Result<Retained<Self>, Retained<NSError>>;
737
738        /// Create an OSLogStore for a subset of entries in the local store.
739        ///
740        ///
741        /// Parameter `scope`: The kind of subset the OSLogStore is for.
742        ///
743        ///
744        /// Parameter `error`: If initialization is unsuccessful, return nil and set this parameter to a
745        /// pointer to an error object that describes the reason.
746        #[unsafe(method(storeWithScope:error:_))]
747        #[unsafe(method_family = none)]
748        pub unsafe fn storeWithScope_error(
749            scope: OSLogStoreScope,
750        ) -> Result<Retained<Self>, Retained<NSError>>;
751
752        /// Create an OSLogStore based on a logarchive.
753        ///
754        ///
755        /// Parameter `url`: The path identifying a logarchive to be read.
756        ///
757        ///
758        /// Parameter `error`: If initialization is unsuccessful --- for example, the path is not
759        /// to a valid logarchive or the logarchive is not compatible because
760        /// it is from a newer version --- return nil and set this parameter
761        /// to a pointer to an error object that describes the reason.
762        #[unsafe(method(storeWithURL:error:_))]
763        #[unsafe(method_family = none)]
764        pub unsafe fn storeWithURL_error(url: &NSURL) -> Result<Retained<Self>, Retained<NSError>>;
765
766        #[deprecated = "Use one of the factory methods"]
767        #[unsafe(method(init))]
768        #[unsafe(method_family = init)]
769        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
770
771        /// Return an OSLogEnumerator object based on an underlying store.
772        /// This object represents the sequence of entries for the store.
773        /// OSLogStore. Additional parameters control which entries are
774        /// yielded and their order.
775        ///
776        ///
777        /// Parameter `options`: Control the direction of iteration.
778        ///
779        ///
780        /// Parameter `position`: Where to start iteration. If nil, depend on the direction of
781        /// the iteration: if forwards, start with the earliest entry; if
782        /// reverse, start with the latest entry.
783        ///
784        ///
785        /// Parameter `predicate`: A predicate that filters which entries are in the sequence. If
786        /// this is nil, yield all entries.
787        ///
788        ///
789        /// Parameter `error`: If the enumerator cannot be set up --- for example, the
790        /// predicate has an unrecognized key --- return nil and set this
791        /// to a pointer to an error object that describes the reason.
792        #[unsafe(method(entriesEnumeratorWithOptions:position:predicate:error:_))]
793        #[unsafe(method_family = none)]
794        pub unsafe fn entriesEnumeratorWithOptions_position_predicate_error(
795            &self,
796            options: OSLogEnumeratorOptions,
797            position: Option<&OSLogPosition>,
798            predicate: Option<&NSPredicate>,
799        ) -> Result<Retained<OSLogEnumerator>, Retained<NSError>>;
800
801        /// Return an OSLogEnumerator object with default options for
802        /// viewing the entries; all are viewed, from earliest to latest.
803        ///
804        ///
805        /// Parameter `error`: If the enumerator cannot be set up, return nil and set this
806        /// to a pointer to an error object that describes the reason.
807        #[unsafe(method(entriesEnumeratorAndReturnError:_))]
808        #[unsafe(method_family = none)]
809        pub unsafe fn entriesEnumeratorAndReturnError(
810            &self,
811        ) -> Result<Retained<OSLogEnumerator>, Retained<NSError>>;
812
813        /// Return a position representing the time specified.
814        ///
815        ///
816        /// Parameter `date`: The date to look for.
817        ///
818        ///
819        /// If there are multiple occurences of the same time --- if, for
820        /// example, there was a time change during the range of entries
821        /// --- the earliest occurrence is used.
822        #[unsafe(method(positionWithDate:))]
823        #[unsafe(method_family = none)]
824        pub unsafe fn positionWithDate(&self, date: &NSDate) -> Retained<OSLogPosition>;
825
826        /// Return a position representing an offset since the end of the time
827        /// range that the entries span.
828        ///
829        ///
830        /// Parameter `seconds`: The seconds to add to the last time point in the range of entries.
831        #[unsafe(method(positionWithTimeIntervalSinceEnd:))]
832        #[unsafe(method_family = none)]
833        pub unsafe fn positionWithTimeIntervalSinceEnd(
834            &self,
835            seconds: NSTimeInterval,
836        ) -> Retained<OSLogPosition>;
837
838        /// Return a position representing time since the last boot in the
839        /// series of entries.
840        ///
841        ///
842        /// Parameter `seconds`: The seconds to add to the boot time point in the log time range.
843        ///
844        ///
845        /// Negative seconds would create an ambiguous or imprecise position;
846        /// this function asserts that the interval is positive.
847        #[unsafe(method(positionWithTimeIntervalSinceLatestBoot:))]
848        #[unsafe(method_family = none)]
849        pub unsafe fn positionWithTimeIntervalSinceLatestBoot(
850            &self,
851            seconds: NSTimeInterval,
852        ) -> Retained<OSLogPosition>;
853    );
854}
855
856/// Methods declared on superclass `NSObject`.
857impl OSLogStore {
858    extern_methods!(
859        #[unsafe(method(new))]
860        #[unsafe(method_family = new)]
861        pub unsafe fn new() -> Retained<Self>;
862    );
863}