use core::ffi::*;
use core::ptr::NonNull;
use objc2::__framework_prelude::*;
use objc2_foundation::*;
use crate::*;
#[repr(transparent)]
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
pub struct PKVehicleConnectionErrorCode(pub NSInteger);
impl PKVehicleConnectionErrorCode {
#[doc(alias = "PKVehicleConnectionErrorCodeUnknown")]
pub const Unknown: Self = Self(0);
#[doc(alias = "PKVehicleConnectionErrorCodeSessionUnableToStart")]
pub const SessionUnableToStart: Self = Self(1);
#[doc(alias = "PKVehicleConnectionErrorCodeSessionNotActive")]
pub const SessionNotActive: Self = Self(2);
}
unsafe impl Encode for PKVehicleConnectionErrorCode {
const ENCODING: Encoding = NSInteger::ENCODING;
}
unsafe impl RefEncode for PKVehicleConnectionErrorCode {
const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
}
#[repr(transparent)]
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
pub struct PKVehicleConnectionSessionConnectionState(pub NSInteger);
impl PKVehicleConnectionSessionConnectionState {
#[doc(alias = "PKVehicleConnectionSessionConnectionStateDisconnected")]
pub const Disconnected: Self = Self(0);
#[doc(alias = "PKVehicleConnectionSessionConnectionStateConnected")]
pub const Connected: Self = Self(1);
#[doc(alias = "PKVehicleConnectionSessionConnectionStateConnecting")]
pub const Connecting: Self = Self(2);
#[doc(alias = "PKVehicleConnectionSessionConnectionStateFailedToConnect")]
pub const FailedToConnect: Self = Self(3);
}
unsafe impl Encode for PKVehicleConnectionSessionConnectionState {
const ENCODING: Encoding = NSInteger::ENCODING;
}
unsafe impl RefEncode for PKVehicleConnectionSessionConnectionState {
const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
}
extern_protocol!(
pub unsafe trait PKVehicleConnectionDelegate: NSObjectProtocol {
#[unsafe(method(sessionDidChangeConnectionState:))]
#[unsafe(method_family = none)]
unsafe fn sessionDidChangeConnectionState(
&self,
new_state: PKVehicleConnectionSessionConnectionState,
);
#[unsafe(method(sessionDidReceiveData:))]
#[unsafe(method_family = none)]
unsafe fn sessionDidReceiveData(&self, data: &NSData);
}
);
extern_class!(
#[unsafe(super(NSObject))]
#[derive(Debug, PartialEq, Eq, Hash)]
pub struct PKVehicleConnectionSession;
);
extern_conformance!(
unsafe impl NSObjectProtocol for PKVehicleConnectionSession {}
);
impl PKVehicleConnectionSession {
extern_methods!(
#[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>;
#[unsafe(method(delegate))]
#[unsafe(method_family = none)]
pub unsafe fn delegate(
&self,
) -> Option<Retained<ProtocolObject<dyn PKVehicleConnectionDelegate>>>;
#[unsafe(method(connectionStatus))]
#[unsafe(method_family = none)]
pub unsafe fn connectionStatus(&self) -> PKVehicleConnectionSessionConnectionState;
#[cfg(all(
feature = "PKObject",
feature = "PKPass",
feature = "PKSecureElementPass",
feature = "block2"
))]
#[unsafe(method(sessionForPass:delegate:completion:))]
#[unsafe(method_family = none)]
pub unsafe fn sessionForPass_delegate_completion(
pass: &PKSecureElementPass,
delegate: &ProtocolObject<dyn PKVehicleConnectionDelegate>,
completion: &block2::DynBlock<dyn Fn(*mut PKVehicleConnectionSession, *mut NSError)>,
);
#[unsafe(method(sendData:error:_))]
#[unsafe(method_family = none)]
pub unsafe fn sendData_error(&self, message: &NSData) -> Result<(), Retained<NSError>>;
#[unsafe(method(invalidate))]
#[unsafe(method_family = none)]
pub unsafe fn invalidate(&self);
);
}