objc2_crypto_token_kit/generated/
TKSmartCardATR.rs

1//! This file has been automatically generated by `objc2`'s `header-translator`.
2//! DO NOT EDIT
3use core::ffi::*;
4use core::ptr::NonNull;
5use objc2::__framework_prelude::*;
6use objc2_foundation::*;
7
8use crate::*;
9
10/// Bitmask of available SmartCard protocols.
11///
12/// See also [Apple's documentation](https://developer.apple.com/documentation/cryptotokenkit/tksmartcardprotocol?language=objc)
13// NS_OPTIONS
14#[repr(transparent)]
15#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
16pub struct TKSmartCardProtocol(pub NSUInteger);
17bitflags::bitflags! {
18    impl TKSmartCardProtocol: NSUInteger {
19        #[doc(alias = "TKSmartCardProtocolNone")]
20        const None = 0;
21        #[doc(alias = "TKSmartCardProtocolT0")]
22        const T0 = 1<<0;
23        #[doc(alias = "TKSmartCardProtocolT1")]
24        const T1 = 1<<1;
25        #[doc(alias = "TKSmartCardProtocolT15")]
26        const T15 = 1<<15;
27        #[doc(alias = "TKSmartCardProtocolAny")]
28        const Any = (1<<16)-1;
29    }
30}
31
32unsafe impl Encode for TKSmartCardProtocol {
33    const ENCODING: Encoding = NSUInteger::ENCODING;
34}
35
36unsafe impl RefEncode for TKSmartCardProtocol {
37    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
38}
39
40extern_class!(
41    /// Represents single interface-bytes group of ATR.
42    ///
43    /// See also [Apple's documentation](https://developer.apple.com/documentation/cryptotokenkit/tksmartcardatrinterfacegroup?language=objc)
44    #[unsafe(super(NSObject))]
45    #[derive(Debug, PartialEq, Eq, Hash)]
46    pub struct TKSmartCardATRInterfaceGroup;
47);
48
49extern_conformance!(
50    unsafe impl NSObjectProtocol for TKSmartCardATRInterfaceGroup {}
51);
52
53impl TKSmartCardATRInterfaceGroup {
54    extern_methods!(
55        /// TA interface byte of ATR group, or nil if TA is not present.
56        #[unsafe(method(TA))]
57        #[unsafe(method_family = none)]
58        pub unsafe fn TA(&self) -> Option<Retained<NSNumber>>;
59
60        /// TB interface byte of ATR group, or nil if TB is not present.
61        #[unsafe(method(TB))]
62        #[unsafe(method_family = none)]
63        pub unsafe fn TB(&self) -> Option<Retained<NSNumber>>;
64
65        /// TC interface byte of ATR group, or nil if TC is not present.
66        #[unsafe(method(TC))]
67        #[unsafe(method_family = none)]
68        pub unsafe fn TC(&self) -> Option<Retained<NSNumber>>;
69
70        /// Protocol number for this group.  First group (global) has protocol unassigned, contains nil.
71        #[unsafe(method(protocol))]
72        #[unsafe(method_family = none)]
73        pub unsafe fn protocol(&self) -> Option<Retained<NSNumber>>;
74    );
75}
76
77/// Methods declared on superclass `NSObject`.
78impl TKSmartCardATRInterfaceGroup {
79    extern_methods!(
80        #[unsafe(method(init))]
81        #[unsafe(method_family = init)]
82        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
83
84        #[unsafe(method(new))]
85        #[unsafe(method_family = new)]
86        pub unsafe fn new() -> Retained<Self>;
87    );
88}
89
90extern_class!(
91    /// Represents parsed SmartCard ATR.  Provides routine for parsing byte stream or NSData with binary ATR and accessors to parsed ATR parts.
92    ///
93    /// See also [Apple's documentation](https://developer.apple.com/documentation/cryptotokenkit/tksmartcardatr?language=objc)
94    #[unsafe(super(NSObject))]
95    #[derive(Debug, PartialEq, Eq, Hash)]
96    pub struct TKSmartCardATR;
97);
98
99extern_conformance!(
100    unsafe impl NSObjectProtocol for TKSmartCardATR {}
101);
102
103impl TKSmartCardATR {
104    extern_methods!(
105        /// Parses ATR from binary data block
106        ///
107        /// Parameter `bytes`: Data containing full valid ATR
108        ///
109        /// Returns: Parsed ATR instance, or nil when #bytes do not contain valid ATR.
110        #[unsafe(method(initWithBytes:))]
111        #[unsafe(method_family = init)]
112        pub unsafe fn initWithBytes(
113            this: Allocated<Self>,
114            bytes: &NSData,
115        ) -> Option<Retained<Self>>;
116
117        #[cfg(feature = "block2")]
118        /// Parses ATR from stream.
119        ///
120        /// Parameter `source`: Provides one byte of ATR from the stream or -1 in case of an error
121        ///
122        /// Returns: Parsed ATR instance, or nil when #source method failed or an invalid ATR is detected
123        #[unsafe(method(initWithSource:))]
124        #[unsafe(method_family = init)]
125        pub unsafe fn initWithSource(
126            this: Allocated<Self>,
127            source: &block2::DynBlock<dyn Fn() -> c_int>,
128        ) -> Option<Retained<Self>>;
129
130        /// Full ATR as string of bytes
131        #[unsafe(method(bytes))]
132        #[unsafe(method_family = none)]
133        pub unsafe fn bytes(&self) -> Retained<NSData>;
134
135        /// Array of NSNumber of protocols indicated in ATR, in the correct order (i.e. the default protocol comes first), duplicates sorted out.
136        #[unsafe(method(protocols))]
137        #[unsafe(method_family = none)]
138        pub unsafe fn protocols(&self) -> Retained<NSArray<NSNumber>>;
139
140        /// Retrieves interface group with specified index.
141        ///
142        /// Parameter `index`: Index of the requested interface group.  Indexing conforms to ISO7816-3, i.e. starts from 1.
143        ///
144        /// Returns: Interface group with given index, or nil of no such group was present.
145        #[unsafe(method(interfaceGroupAtIndex:))]
146        #[unsafe(method_family = none)]
147        pub unsafe fn interfaceGroupAtIndex(
148            &self,
149            index: NSInteger,
150        ) -> Option<Retained<TKSmartCardATRInterfaceGroup>>;
151
152        /// Parameter `protocol`: Protocol number for which the interface group is requested.
153        #[unsafe(method(interfaceGroupForProtocol:))]
154        #[unsafe(method_family = none)]
155        pub unsafe fn interfaceGroupForProtocol(
156            &self,
157            protocol: TKSmartCardProtocol,
158        ) -> Option<Retained<TKSmartCardATRInterfaceGroup>>;
159
160        /// Just historical bytes of ATR, without Tck and interface bytes.
161        #[unsafe(method(historicalBytes))]
162        #[unsafe(method_family = none)]
163        pub unsafe fn historicalBytes(&self) -> Retained<NSData>;
164
165        #[cfg(feature = "TKTLVRecord")]
166        /// An array of TKCompactTLVRecord instances with TLV records parsed from historical bytes.  If historical bytes are
167        /// not structured using Compact TLV encoding, nil is returned.
168        ///
169        /// Note: In case that ATR historical bytes begin with 0x00, the last three bytes (status indicator) are automatically
170        /// appended into the returned records as if historical bytes would begin with 0x80 and 0x8 record is present
171        /// in historical bytes.
172        #[unsafe(method(historicalRecords))]
173        #[unsafe(method_family = none)]
174        pub unsafe fn historicalRecords(&self) -> Option<Retained<NSArray<TKCompactTLVRecord>>>;
175    );
176}
177
178/// Methods declared on superclass `NSObject`.
179impl TKSmartCardATR {
180    extern_methods!(
181        #[unsafe(method(init))]
182        #[unsafe(method_family = init)]
183        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
184
185        #[unsafe(method(new))]
186        #[unsafe(method_family = new)]
187        pub unsafe fn new() -> Retained<Self>;
188    );
189}