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 CBCharacteristicProperties(pub NSUInteger);
bitflags::bitflags! {
impl CBCharacteristicProperties: NSUInteger {
#[doc(alias = "CBCharacteristicPropertyBroadcast")]
const Broadcast = 0x01;
#[doc(alias = "CBCharacteristicPropertyRead")]
const Read = 0x02;
#[doc(alias = "CBCharacteristicPropertyWriteWithoutResponse")]
const WriteWithoutResponse = 0x04;
#[doc(alias = "CBCharacteristicPropertyWrite")]
const Write = 0x08;
#[doc(alias = "CBCharacteristicPropertyNotify")]
const Notify = 0x10;
#[doc(alias = "CBCharacteristicPropertyIndicate")]
const Indicate = 0x20;
#[doc(alias = "CBCharacteristicPropertyAuthenticatedSignedWrites")]
const AuthenticatedSignedWrites = 0x40;
#[doc(alias = "CBCharacteristicPropertyExtendedProperties")]
const ExtendedProperties = 0x80;
#[doc(alias = "CBCharacteristicPropertyNotifyEncryptionRequired")]
const NotifyEncryptionRequired = 0x100;
#[doc(alias = "CBCharacteristicPropertyIndicateEncryptionRequired")]
const IndicateEncryptionRequired = 0x200;
}
}
unsafe impl Encode for CBCharacteristicProperties {
const ENCODING: Encoding = NSUInteger::ENCODING;
}
unsafe impl RefEncode for CBCharacteristicProperties {
const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
}
extern_class!(
#[unsafe(super(CBAttribute, NSObject))]
#[derive(Debug, PartialEq, Eq, Hash)]
#[cfg(feature = "CBAttribute")]
pub struct CBCharacteristic;
);
#[cfg(feature = "CBAttribute")]
extern_conformance!(
unsafe impl NSObjectProtocol for CBCharacteristic {}
);
#[cfg(feature = "CBAttribute")]
impl CBCharacteristic {
extern_methods!(
#[cfg(feature = "CBService")]
#[unsafe(method(service))]
#[unsafe(method_family = none)]
pub unsafe fn service(&self) -> Option<Retained<CBService>>;
#[unsafe(method(properties))]
#[unsafe(method_family = none)]
pub unsafe fn properties(&self) -> CBCharacteristicProperties;
#[unsafe(method(value))]
#[unsafe(method_family = none)]
pub unsafe fn value(&self) -> Option<Retained<NSData>>;
#[cfg(feature = "CBDescriptor")]
#[unsafe(method(descriptors))]
#[unsafe(method_family = none)]
pub unsafe fn descriptors(&self) -> Option<Retained<NSArray<CBDescriptor>>>;
#[deprecated]
#[unsafe(method(isBroadcasted))]
#[unsafe(method_family = none)]
pub unsafe fn isBroadcasted(&self) -> bool;
#[unsafe(method(isNotifying))]
#[unsafe(method_family = none)]
pub unsafe fn isNotifying(&self) -> bool;
);
}
#[cfg(feature = "CBAttribute")]
impl CBCharacteristic {
extern_methods!(
#[unsafe(method(init))]
#[unsafe(method_family = init)]
pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
);
}
#[cfg(feature = "CBAttribute")]
impl CBCharacteristic {
extern_methods!(
#[unsafe(method(new))]
#[unsafe(method_family = new)]
pub unsafe fn new() -> Retained<Self>;
);
}
#[repr(transparent)]
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
pub struct CBAttributePermissions(pub NSUInteger);
bitflags::bitflags! {
impl CBAttributePermissions: NSUInteger {
#[doc(alias = "CBAttributePermissionsReadable")]
const Readable = 0x01;
#[doc(alias = "CBAttributePermissionsWriteable")]
const Writeable = 0x02;
#[doc(alias = "CBAttributePermissionsReadEncryptionRequired")]
const ReadEncryptionRequired = 0x04;
#[doc(alias = "CBAttributePermissionsWriteEncryptionRequired")]
const WriteEncryptionRequired = 0x08;
}
}
unsafe impl Encode for CBAttributePermissions {
const ENCODING: Encoding = NSUInteger::ENCODING;
}
unsafe impl RefEncode for CBAttributePermissions {
const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
}
extern_class!(
#[unsafe(super(CBCharacteristic, CBAttribute, NSObject))]
#[derive(Debug, PartialEq, Eq, Hash)]
#[cfg(feature = "CBAttribute")]
pub struct CBMutableCharacteristic;
);
#[cfg(feature = "CBAttribute")]
extern_conformance!(
unsafe impl NSObjectProtocol for CBMutableCharacteristic {}
);
#[cfg(feature = "CBAttribute")]
impl CBMutableCharacteristic {
extern_methods!(
#[unsafe(method(permissions))]
#[unsafe(method_family = none)]
pub unsafe fn permissions(&self) -> CBAttributePermissions;
#[unsafe(method(setPermissions:))]
#[unsafe(method_family = none)]
pub unsafe fn setPermissions(&self, permissions: CBAttributePermissions);
#[cfg(all(feature = "CBCentral", feature = "CBPeer"))]
#[unsafe(method(subscribedCentrals))]
#[unsafe(method_family = none)]
pub unsafe fn subscribedCentrals(&self) -> Option<Retained<NSArray<CBCentral>>>;
#[unsafe(method(properties))]
#[unsafe(method_family = none)]
pub unsafe fn properties(&self) -> CBCharacteristicProperties;
#[unsafe(method(setProperties:))]
#[unsafe(method_family = none)]
pub unsafe fn setProperties(&self, properties: CBCharacteristicProperties);
#[unsafe(method(value))]
#[unsafe(method_family = none)]
pub unsafe fn value(&self) -> Option<Retained<NSData>>;
#[unsafe(method(setValue:))]
#[unsafe(method_family = none)]
pub unsafe fn setValue(&self, value: Option<&NSData>);
#[cfg(feature = "CBDescriptor")]
#[unsafe(method(descriptors))]
#[unsafe(method_family = none)]
pub unsafe fn descriptors(&self) -> Option<Retained<NSArray<CBDescriptor>>>;
#[cfg(feature = "CBDescriptor")]
#[unsafe(method(setDescriptors:))]
#[unsafe(method_family = none)]
pub unsafe fn setDescriptors(&self, descriptors: Option<&NSArray<CBDescriptor>>);
#[cfg(feature = "CBUUID")]
#[unsafe(method(initWithType:properties:value:permissions:))]
#[unsafe(method_family = init)]
pub unsafe fn initWithType_properties_value_permissions(
this: Allocated<Self>,
uuid: &CBUUID,
properties: CBCharacteristicProperties,
value: Option<&NSData>,
permissions: CBAttributePermissions,
) -> Retained<Self>;
);
}
#[cfg(feature = "CBAttribute")]
impl CBMutableCharacteristic {
extern_methods!(
#[unsafe(method(init))]
#[unsafe(method_family = init)]
pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
);
}
#[cfg(feature = "CBAttribute")]
impl CBMutableCharacteristic {
extern_methods!(
#[unsafe(method(new))]
#[unsafe(method_family = new)]
pub unsafe fn new() -> Retained<Self>;
);
}