objc2_crypto_token_kit/generated/
TKTLVRecord.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
9/// Type used for identifying TLV format tags.
10/// Although for some encodings tags can have theoretically any length,
11/// this implementation supports tag length only up to 64bits.
12///
13/// See also [Apple's documentation](https://developer.apple.com/documentation/cryptotokenkit/tktlvtag?language=objc)
14pub type TKTLVTag = u64;
15
16extern_class!(
17    /// Base class representing Tag-Length-Value record.
18    /// Every record has its tag and binary value represented as NSData instance.  Allows retrieving record's tag,
19    /// value (as NSData object) and binary representation of the record. Existing subclasses implement assorted
20    /// encodings - TKBERTLVRecord, TKSimpleTLVRecord and TKCompactTLVRecord.
21    ///
22    /// See also [Apple's documentation](https://developer.apple.com/documentation/cryptotokenkit/tktlvrecord?language=objc)
23    #[unsafe(super(NSObject))]
24    #[derive(Debug, PartialEq, Eq, Hash)]
25    pub struct TKTLVRecord;
26);
27
28extern_conformance!(
29    unsafe impl NSObjectProtocol for TKTLVRecord {}
30);
31
32impl TKTLVRecord {
33    extern_methods!(
34        /// Tag value of the record.
35        #[unsafe(method(tag))]
36        #[unsafe(method_family = none)]
37        pub unsafe fn tag(&self) -> TKTLVTag;
38
39        /// Value field of the record.
40        #[unsafe(method(value))]
41        #[unsafe(method_family = none)]
42        pub unsafe fn value(&self) -> Retained<NSData>;
43
44        /// Data object containing whole encoded record, including tag, length and value.
45        #[unsafe(method(data))]
46        #[unsafe(method_family = none)]
47        pub unsafe fn data(&self) -> Retained<NSData>;
48
49        /// Parses TLV record from data block
50        ///
51        /// Parameter `data`: Data block containing serialized form of TLV record.
52        ///
53        /// Returns: newly parsed record instance or nil if data do not represent valid record.
54        #[unsafe(method(recordFromData:))]
55        #[unsafe(method_family = none)]
56        pub unsafe fn recordFromData(data: &NSData) -> Option<Retained<Self>>;
57
58        /// Parses sequence of TLV records from data block.
59        /// The amount of records is determined by the length of input data block.
60        ///
61        /// Parameter `data`: Data block containing zero or more serialized forms of TLV record.
62        ///
63        /// Returns: An array of TLV record instances parsed from input data block or nil if data do not form valid TLV record sequence.
64        #[unsafe(method(sequenceOfRecordsFromData:))]
65        #[unsafe(method_family = none)]
66        pub unsafe fn sequenceOfRecordsFromData(
67            data: &NSData,
68        ) -> Option<Retained<NSArray<TKTLVRecord>>>;
69
70        #[unsafe(method(init))]
71        #[unsafe(method_family = init)]
72        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
73    );
74}
75
76/// Methods declared on superclass `NSObject`.
77impl TKTLVRecord {
78    extern_methods!(
79        #[unsafe(method(new))]
80        #[unsafe(method_family = new)]
81        pub unsafe fn new() -> Retained<Self>;
82    );
83}
84
85extern_class!(
86    /// TKBERTLVRecord implements encoding using BER-TLV encoding rules.
87    /// It is able to parse BER-encoded data and always produces DER-encoded data.
88    /// No interpretation of tag values is made, all values are treated only as NSData irrespective of the tag.
89    ///
90    /// See also [Apple's documentation](https://developer.apple.com/documentation/cryptotokenkit/tkbertlvrecord?language=objc)
91    #[unsafe(super(TKTLVRecord, NSObject))]
92    #[derive(Debug, PartialEq, Eq, Hash)]
93    pub struct TKBERTLVRecord;
94);
95
96extern_conformance!(
97    unsafe impl NSObjectProtocol for TKBERTLVRecord {}
98);
99
100impl TKBERTLVRecord {
101    extern_methods!(
102        /// Encodes tag using BER-TLV tag encoding rules.
103        ///
104        /// Parameter `tag`: Tag value to encode
105        ///
106        /// Returns: Binary block containing encoded tag value.
107        #[unsafe(method(dataForTag:))]
108        #[unsafe(method_family = none)]
109        pub unsafe fn dataForTag(tag: TKTLVTag) -> Retained<NSData>;
110
111        /// Creates TLV record with specified tag and value.
112        ///
113        /// Parameter `tag`: Tag value for the new record.
114        ///
115        /// Parameter `value`: Value for the new record.
116        ///
117        /// Returns: Newly created TLV record.
118        #[unsafe(method(initWithTag:value:))]
119        #[unsafe(method_family = init)]
120        pub unsafe fn initWithTag_value(
121            this: Allocated<Self>,
122            tag: TKTLVTag,
123            value: &NSData,
124        ) -> Retained<Self>;
125
126        /// Creates TKBERTLVRecord with specified tag and array of children TKTLVRecord instances as subrecords.
127        ///
128        /// Parameter `tag`: Tag value for the new record.
129        ///
130        /// Parameter `records`: Array of TKTLVRecord instances serving as subrecords of this record.
131        ///
132        /// Returns: Newly created TLV record.
133        #[unsafe(method(initWithTag:records:))]
134        #[unsafe(method_family = init)]
135        pub unsafe fn initWithTag_records(
136            this: Allocated<Self>,
137            tag: TKTLVTag,
138            records: &NSArray<TKTLVRecord>,
139        ) -> Retained<Self>;
140    );
141}
142
143/// Methods declared on superclass `TKTLVRecord`.
144impl TKBERTLVRecord {
145    extern_methods!(
146        /// Parses TLV record from data block
147        ///
148        /// Parameter `data`: Data block containing serialized form of TLV record.
149        ///
150        /// Returns: newly parsed record instance or nil if data do not represent valid record.
151        #[unsafe(method(recordFromData:))]
152        #[unsafe(method_family = none)]
153        pub unsafe fn recordFromData(data: &NSData) -> Option<Retained<Self>>;
154
155        #[unsafe(method(init))]
156        #[unsafe(method_family = init)]
157        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
158    );
159}
160
161/// Methods declared on superclass `NSObject`.
162impl TKBERTLVRecord {
163    extern_methods!(
164        #[unsafe(method(new))]
165        #[unsafe(method_family = new)]
166        pub unsafe fn new() -> Retained<Self>;
167    );
168}
169
170extern_class!(
171    /// TKSimpleTLVRecord implements Simple-TLV encoding according to ISO7816-4.
172    /// Tag is number in range
173    /// <
174    /// 1..254> encoded as single byte, length is either single byte specifying length 0-254
175    /// or 3 bytes encoded as 0xff followed by 2 bytes of big-endian encoded number.
176    ///
177    /// See also [Apple's documentation](https://developer.apple.com/documentation/cryptotokenkit/tksimpletlvrecord?language=objc)
178    #[unsafe(super(TKTLVRecord, NSObject))]
179    #[derive(Debug, PartialEq, Eq, Hash)]
180    pub struct TKSimpleTLVRecord;
181);
182
183extern_conformance!(
184    unsafe impl NSObjectProtocol for TKSimpleTLVRecord {}
185);
186
187impl TKSimpleTLVRecord {
188    extern_methods!(
189        /// Creates TLV record with specified tag and value.
190        ///
191        /// Parameter `tag`: Tag value for the new record.
192        ///
193        /// Parameter `value`: Value for the new record.
194        ///
195        /// Returns: Newly created TLV record.
196        #[unsafe(method(initWithTag:value:))]
197        #[unsafe(method_family = init)]
198        pub unsafe fn initWithTag_value(
199            this: Allocated<Self>,
200            tag: u8,
201            value: &NSData,
202        ) -> Retained<Self>;
203    );
204}
205
206/// Methods declared on superclass `TKTLVRecord`.
207impl TKSimpleTLVRecord {
208    extern_methods!(
209        /// Parses TLV record from data block
210        ///
211        /// Parameter `data`: Data block containing serialized form of TLV record.
212        ///
213        /// Returns: newly parsed record instance or nil if data do not represent valid record.
214        #[unsafe(method(recordFromData:))]
215        #[unsafe(method_family = none)]
216        pub unsafe fn recordFromData(data: &NSData) -> Option<Retained<Self>>;
217
218        #[unsafe(method(init))]
219        #[unsafe(method_family = init)]
220        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
221    );
222}
223
224/// Methods declared on superclass `NSObject`.
225impl TKSimpleTLVRecord {
226    extern_methods!(
227        #[unsafe(method(new))]
228        #[unsafe(method_family = new)]
229        pub unsafe fn new() -> Retained<Self>;
230    );
231}
232
233extern_class!(
234    /// TKCompactTLVRecord implements Compact-TLV encoding according to ISO7816-4
235    /// Tag is number in range
236    /// <
237    /// 0..15> encoded as high 4 bits of initial byte, length is number in range
238    /// <
239    /// 0..15>
240    /// encoded as low 4 bits of initial byte.  Value immediatelly follows leading byte.
241    ///
242    /// See also [Apple's documentation](https://developer.apple.com/documentation/cryptotokenkit/tkcompacttlvrecord?language=objc)
243    #[unsafe(super(TKTLVRecord, NSObject))]
244    #[derive(Debug, PartialEq, Eq, Hash)]
245    pub struct TKCompactTLVRecord;
246);
247
248extern_conformance!(
249    unsafe impl NSObjectProtocol for TKCompactTLVRecord {}
250);
251
252impl TKCompactTLVRecord {
253    extern_methods!(
254        /// Creates TLV record with specified tag and value.
255        ///
256        /// Parameter `tag`: Tag value for the new record.
257        ///
258        /// Parameter `value`: Value for the new record.
259        ///
260        /// Returns: Newly created TLV record.
261        #[unsafe(method(initWithTag:value:))]
262        #[unsafe(method_family = init)]
263        pub unsafe fn initWithTag_value(
264            this: Allocated<Self>,
265            tag: u8,
266            value: &NSData,
267        ) -> Retained<Self>;
268    );
269}
270
271/// Methods declared on superclass `TKTLVRecord`.
272impl TKCompactTLVRecord {
273    extern_methods!(
274        /// Parses TLV record from data block
275        ///
276        /// Parameter `data`: Data block containing serialized form of TLV record.
277        ///
278        /// Returns: newly parsed record instance or nil if data do not represent valid record.
279        #[unsafe(method(recordFromData:))]
280        #[unsafe(method_family = none)]
281        pub unsafe fn recordFromData(data: &NSData) -> Option<Retained<Self>>;
282
283        #[unsafe(method(init))]
284        #[unsafe(method_family = init)]
285        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
286    );
287}
288
289/// Methods declared on superclass `NSObject`.
290impl TKCompactTLVRecord {
291    extern_methods!(
292        #[unsafe(method(new))]
293        #[unsafe(method_family = new)]
294        pub unsafe fn new() -> Retained<Self>;
295    );
296}