objc2-crypto-token-kit 0.3.2

Bindings to the CryptoTokenKit framework
Documentation
//! This file has been automatically generated by `objc2`'s `header-translator`.
//! DO NOT EDIT
use core::ffi::*;
use core::ptr::NonNull;
use objc2::__framework_prelude::*;
use objc2_foundation::*;

use crate::*;

extern_class!(
    /// [Apple's documentation](https://developer.apple.com/documentation/cryptotokenkit/tktokenwatchertokeninfo?language=objc)
    #[unsafe(super(NSObject))]
    #[derive(Debug, PartialEq, Eq, Hash)]
    pub struct TKTokenWatcherTokenInfo;
);

extern_conformance!(
    unsafe impl NSObjectProtocol for TKTokenWatcherTokenInfo {}
);

impl TKTokenWatcherTokenInfo {
    extern_methods!(
        /// TokenID
        #[unsafe(method(tokenID))]
        #[unsafe(method_family = none)]
        pub unsafe fn tokenID(&self) -> Retained<NSString>;

        /// The slot name (if available)
        #[unsafe(method(slotName))]
        #[unsafe(method_family = none)]
        pub unsafe fn slotName(&self) -> Option<Retained<NSString>>;

        /// Localized driver name (if available)
        #[unsafe(method(driverName))]
        #[unsafe(method_family = none)]
        pub unsafe fn driverName(&self) -> Option<Retained<NSString>>;

        #[unsafe(method(init))]
        #[unsafe(method_family = init)]
        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;

        #[unsafe(method(new))]
        #[unsafe(method_family = new)]
        pub unsafe fn new() -> Retained<Self>;
    );
}

extern_class!(
    /// [Apple's documentation](https://developer.apple.com/documentation/cryptotokenkit/tktokenwatcher?language=objc)
    #[unsafe(super(NSObject))]
    #[derive(Debug, PartialEq, Eq, Hash)]
    pub struct TKTokenWatcher;
);

extern_conformance!(
    unsafe impl NSObjectProtocol for TKTokenWatcher {}
);

impl TKTokenWatcher {
    extern_methods!(
        /// Array of currently known TokenIDs in the system.  Tokens are identified by instance's names. It is possible to use KVO to be notified about token arrivals and removals.
        #[unsafe(method(tokenIDs))]
        #[unsafe(method_family = none)]
        pub unsafe fn tokenIDs(&self) -> Retained<NSArray<NSString>>;

        /// Init watcher
        #[unsafe(method(init))]
        #[unsafe(method_family = init)]
        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;

        #[cfg(feature = "block2")]
        /// Init watcher with insertion handler
        ///
        /// init watcher with insertion handler which is called when a new token arrives
        ///
        /// Parameter `insertionHandler`: called when a new token is inserted
        #[deprecated]
        #[unsafe(method(initWithInsertionHandler:))]
        #[unsafe(method_family = init)]
        pub unsafe fn initWithInsertionHandler(
            this: Allocated<Self>,
            insertion_handler: &block2::DynBlock<dyn Fn(NonNull<NSString>)>,
        ) -> Retained<Self>;

        #[cfg(feature = "block2")]
        /// Set insertion handler
        ///
        /// when an insertion handler is set the TokenWatcher will call this handler when new token appears in the system. TokenWatcher will call the handler also for tokens which was registered in the system before the handler was set.
        ///
        /// Parameter `insertionHandler`: called when a new token is inserted
        #[unsafe(method(setInsertionHandler:))]
        #[unsafe(method_family = none)]
        pub unsafe fn setInsertionHandler(
            &self,
            insertion_handler: &block2::DynBlock<dyn Fn(NonNull<NSString>)>,
        );

        #[cfg(feature = "block2")]
        /// Add removal watcher for specific tokenID
        ///
        /// after removalHandler for a specific tokenID is called the reference to this handler is removed. For one tokenID just one handler can be added, so next call to addRemovalHandler will replace previous handler
        ///
        /// Parameter `removalHandler`: called when a token is removed
        ///
        /// Parameter `tokenID`: specified tokenID, if tokenID does not exist removal handler is called imediately
        #[unsafe(method(addRemovalHandler:forTokenID:))]
        #[unsafe(method_family = none)]
        pub unsafe fn addRemovalHandler_forTokenID(
            &self,
            removal_handler: &block2::DynBlock<dyn Fn(NonNull<NSString>)>,
            token_id: &NSString,
        );

        /// Return TokenInfo for specific tokenID
        ///
        /// Parameter `tokenID`: specified tokenID
        ///
        /// Returns: A TokenInfo object, or nil if tokenID does not exist
        #[unsafe(method(tokenInfoForTokenID:))]
        #[unsafe(method_family = none)]
        pub unsafe fn tokenInfoForTokenID(
            &self,
            token_id: &NSString,
        ) -> Option<Retained<TKTokenWatcherTokenInfo>>;
    );
}

/// Methods declared on superclass `NSObject`.
impl TKTokenWatcher {
    extern_methods!(
        #[unsafe(method(new))]
        #[unsafe(method_family = new)]
        pub unsafe fn new() -> Retained<Self>;
    );
}