IONotificationPort

Struct IONotificationPort 

Source
pub struct IONotificationPort { /* private fields */ }
Expand description

Implementations§

Source§

impl IONotificationPort

Source

pub fn create(main_port: mach_port_t) -> IONotificationPortRef

Available on crate feature libc only.

Creates and returns a notification object for receiving IOKit notifications of new devices or state changes.

Creates the notification object to receive notifications from IOKit of new device arrivals or state changes. The notification object can be supply a CFRunLoopSource, or mach_port_t to be used to listen for events.

Parameter mainPort: The main port obtained from IOMainPort(). Pass kIOMainPortDefault to look up the default main port.

Returns: A reference to the notification object.

Source

pub unsafe fn destroy(notify: IONotificationPortRef)

Destroys a notification object created with IONotificationPortCreate. Also destroys any mach_port’s or CFRunLoopSources obtained from

 IONotificationPortGetRunLoopSource
or
 IONotificationPortGetMachPort

Parameter notify: A reference to the notification object.

§Safety

notify must be a valid pointer.

Source

pub unsafe fn run_loop_source( notify: IONotificationPortRef, ) -> Option<CFRetained<CFRunLoopSource>>

Returns a CFRunLoopSource to be used to listen for notifications.

A notification object may deliver notifications to a CFRunLoop by adding the run loop source returned by this function to the run loop.

The caller should not release this CFRunLoopSource. Just call

 IONotificationPortDestroy
to dispose of the IONotificationPortRef and the CFRunLoopSource when done.

Parameter notify: The notification object.

Returns: A CFRunLoopSourceRef for the notification object.

§Safety

notify must be a valid pointer.

Source

pub unsafe fn mach_port(notify: IONotificationPortRef) -> mach_port_t

Available on crate feature libc only.

Returns a mach_port to be used to listen for notifications.

A notification object may deliver notifications to a mach messaging client if they listen for messages on the port obtained from this function. Callbacks associated with the notifications may be delivered by calling IODispatchCalloutFromMessage with messages received.

The caller should not release this mach_port_t. Just call

 IONotificationPortDestroy
to dispose of the mach_port_t and IONotificationPortRef when done.

Parameter notify: The notification object.

Returns: A mach_port for the notification object.

§Safety

notify must be a valid pointer.

Source

pub unsafe fn set_importance_receiver( notify: IONotificationPortRef, ) -> kern_return_t

Available on crate feature libc only.

Configure a notification port to be an importance receiver.

Sets the MACH_PORT_IMPORTANCE_RECEIVER attribute on the underlying mach port. Importance-donating messages sent to a notification port with this attribute enabled will boost the importance of the receiving process for the duration of the notification handler.

Parameter notify: The notification object.

Returns: A kern_return_t error code.

§Safety

notify must be a valid pointer.

Source

pub unsafe fn set_dispatch_queue( notify: IONotificationPortRef, queue: Option<&DispatchQueue>, )

Available on crate feature dispatch2 only.

Sets a dispatch queue to be used to listen for notifications.

A notification object may deliver notifications to a dispatch client.

Parameter notify: The notification object.

Parameter queue: A dispatch queue.

§Safety
  • notify must be a valid pointer.
  • queue possibly has additional threading requirements.
  • queue might not allow None.

Trait Implementations§

Source§

impl Debug for IONotificationPort

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl RefEncode for IONotificationPort

Available on crate feature objc2 only.
Source§

const ENCODING_REF: Encoding

The Objective-C type-encoding for a reference of this type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> AutoreleaseSafe for T
where T: ?Sized,