objc2_web_kit/generated/
WKWebExtensionDataRecord.rs

1//! This file has been automatically generated by `objc2`'s `header-translator`.
2//! DO NOT EDIT
3use core::ptr::NonNull;
4use objc2::__framework_prelude::*;
5use objc2_foundation::*;
6
7use crate::*;
8
9extern "C" {
10    /// Indicates a ``WKWebExtensionDataRecord`` error.
11    ///
12    /// See also [Apple's documentation](https://developer.apple.com/documentation/webkit/wkwebextensiondatarecorderrordomain?language=objc)
13    pub static WKWebExtensionDataRecordErrorDomain: &'static NSErrorDomain;
14}
15
16/// Constants used by ``NSError`` to indicate errors in the ``WKWebExtensionDataRecord`` domain.
17///
18/// See also [Apple's documentation](https://developer.apple.com/documentation/webkit/wkwebextensiondatarecorderror?language=objc)
19// NS_ERROR_ENUM
20#[repr(transparent)]
21#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
22pub struct WKWebExtensionDataRecordError(pub NSInteger);
23impl WKWebExtensionDataRecordError {
24    #[doc(alias = "WKWebExtensionDataRecordErrorUnknown")]
25    pub const Unknown: Self = Self(1);
26    #[doc(alias = "WKWebExtensionDataRecordErrorLocalStorageFailed")]
27    pub const LocalStorageFailed: Self = Self(2);
28    #[doc(alias = "WKWebExtensionDataRecordErrorSessionStorageFailed")]
29    pub const SessionStorageFailed: Self = Self(3);
30    #[doc(alias = "WKWebExtensionDataRecordErrorSynchronizedStorageFailed")]
31    pub const SynchronizedStorageFailed: Self = Self(4);
32}
33
34unsafe impl Encode for WKWebExtensionDataRecordError {
35    const ENCODING: Encoding = NSInteger::ENCODING;
36}
37
38unsafe impl RefEncode for WKWebExtensionDataRecordError {
39    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
40}
41
42extern_class!(
43    /// A ``WKWebExtensionDataRecord`` object represents a record of stored data for a specific web extension context.
44    ///
45    /// Contains properties and methods to query the data types and sizes.
46    ///
47    /// See also [Apple's documentation](https://developer.apple.com/documentation/webkit/wkwebextensiondatarecord?language=objc)
48    #[unsafe(super(NSObject))]
49    #[thread_kind = MainThreadOnly]
50    #[derive(Debug, PartialEq, Eq, Hash)]
51    pub struct WKWebExtensionDataRecord;
52);
53
54extern_conformance!(
55    unsafe impl NSObjectProtocol for WKWebExtensionDataRecord {}
56);
57
58impl WKWebExtensionDataRecord {
59    extern_methods!(
60        #[unsafe(method(new))]
61        #[unsafe(method_family = new)]
62        pub unsafe fn new(mtm: MainThreadMarker) -> Retained<Self>;
63
64        #[unsafe(method(init))]
65        #[unsafe(method_family = init)]
66        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
67
68        /// The display name for the web extension to which this data record belongs.
69        #[unsafe(method(displayName))]
70        #[unsafe(method_family = none)]
71        pub unsafe fn displayName(&self) -> Retained<NSString>;
72
73        /// Unique identifier for the web extension context to which this data record belongs.
74        #[unsafe(method(uniqueIdentifier))]
75        #[unsafe(method_family = none)]
76        pub unsafe fn uniqueIdentifier(&self) -> Retained<NSString>;
77
78        #[cfg(feature = "WKWebExtensionDataType")]
79        /// The set of data types contained in this data record.
80        #[unsafe(method(containedDataTypes))]
81        #[unsafe(method_family = none)]
82        pub unsafe fn containedDataTypes(&self) -> Retained<NSSet<WKWebExtensionDataType>>;
83
84        /// An array of errors that may have occurred when either calculating or deleting storage.
85        #[unsafe(method(errors))]
86        #[unsafe(method_family = none)]
87        pub unsafe fn errors(&self) -> Retained<NSArray<NSError>>;
88
89        /// The total size in bytes of all data types contained in this data record.
90        ///
91        /// See also: sizeInBytesOfTypes:
92        #[unsafe(method(totalSizeInBytes))]
93        #[unsafe(method_family = none)]
94        pub unsafe fn totalSizeInBytes(&self) -> NSUInteger;
95
96        #[cfg(feature = "WKWebExtensionDataType")]
97        /// Retrieves the size in bytes of the specific data types in this data record.
98        ///
99        /// Parameter `dataTypes`: The set of data types to measure the size for.
100        ///
101        /// Returns: The total size of the specified data types.
102        ///
103        /// See also: totalSizeInBytes
104        #[unsafe(method(sizeInBytesOfTypes:))]
105        #[unsafe(method_family = none)]
106        pub unsafe fn sizeInBytesOfTypes(
107            &self,
108            data_types: &NSSet<WKWebExtensionDataType>,
109        ) -> NSUInteger;
110    );
111}