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