pub struct AXObserver { /* private fields */ }AXUIElement and HIServices only.Expand description
An AXObserverRef is a CFType. Like all CFTypes, they are reference counted (
//apple_ref/c/func/CFRetain CFRetain,
//apple_ref/c/func/CFRelease CFRelease).
See also Apple’s documentation
Implementations§
Source§impl AXObserver
impl AXObserver
Sourcepub unsafe fn create(
application: pid_t,
callback: AXObserverCallback,
out_observer: NonNull<*mut AXObserver>,
) -> AXError
Available on crate features AXError and libc only.
pub unsafe fn create( application: pid_t, callback: AXObserverCallback, out_observer: NonNull<*mut AXObserver>, ) -> AXError
AXError and libc only.Creates a new observer that can receive notifications from the specified application.
When an observed notification is received, it is passed to
AXObserverCallback AXObserverCallback.
Parameter application: The process ID of the application.
Parameter callback: The callback function.
Parameter outObserver: On return, an AXObserverRef representing the observer object.
Returns: If unsuccessful,
AXObserverCreate
may return one of the following error codes, among others:
-
kAXErrorIllegalArgument - One or more of the arguments is an illegal value.
-
kAXErrorFailure - There is some sort of system memory failure.
§Safety
callbackmust be implemented correctly.out_observermust be a valid pointer.
Sourcepub unsafe fn create_with_info_callback(
application: pid_t,
callback: AXObserverCallbackWithInfo,
out_observer: NonNull<*mut AXObserver>,
) -> AXError
Available on crate features AXError and libc only.
pub unsafe fn create_with_info_callback( application: pid_t, callback: AXObserverCallbackWithInfo, out_observer: NonNull<*mut AXObserver>, ) -> AXError
AXError and libc only.Creates a new observer that can receive notifications with an information dictionary from the specified application.
When an observed notification is received, it is passed to
AXObserverCallbackWithInfo AXObserverCallbackWithInfo.
Parameter application: The process ID of the application.
Parameter callback: The callback function.
Parameter outObserver: On return, an AXObserverRef representing the observer object.
Returns: If unsuccessful,
AXObserverCreateWithInfoCallback
may return one of the following error codes, among others:
-
kAXErrorIllegalArgument - One or more of the arguments is an illegal value.
-
kAXErrorFailure - There is some sort of system memory failure.
§Safety
callbackmust be implemented correctly.out_observermust be a valid pointer.
Sourcepub unsafe fn add_notification(
&self,
element: &AXUIElement,
notification: &CFString,
refcon: *mut c_void,
) -> AXError
Available on crate feature AXError only.
pub unsafe fn add_notification( &self, element: &AXUIElement, notification: &CFString, refcon: *mut c_void, ) -> AXError
AXError only.Registers the specified observer to receive notifications from the specified accessibility object.
Parameter observer: The observer object created from a call to
AXObserverCreate AXObserverCreate.
Parameter element: The accessibility object for which to observe notifications.
Parameter notification: The name of the notification to observe.
Parameter refcon: Application-defined data passed to the callback when it is called.
Returns: If unsuccessful,
AXObserverAddNotification
may return one of the following error codes, among others:
-
kAXErrorInvalidUIElementObserver - The observer is not a valid AXObserverRef type.
-
kAXErrorIllegalArgument - One or more of the arguments is an illegal value or the length of the notification name is greater than 1024.
-
kAXErrorNotificationUnsupported - The accessibility object does not support notifications (note that the system-wide accessibility object does not support notifications).
-
kAXErrorNotificationAlreadyRegistered - The notification has already been registered.
-
kAXErrorCannotComplete - The function cannot complete because messaging has failed in some way.
-
kAXErrorFailure - There is some sort of system memory failure.
§Safety
refcon must be a valid pointer or null.
Sourcepub unsafe fn remove_notification(
&self,
element: &AXUIElement,
notification: &CFString,
) -> AXError
Available on crate feature AXError only.
pub unsafe fn remove_notification( &self, element: &AXUIElement, notification: &CFString, ) -> AXError
AXError only.Removes the specified notification from the list of notifications the observer wants to receive from the accessibility object.
Parameter observer: The observer object created from a call to
AXObserverCreate AXObserverCreate.
Parameter element: The accessibility object for which this observer observes notifications.
Parameter notification: The name of the notification to remove from the list of observed notifications.
Returns: If unsuccessful,
AXObserverRemoveNotification
may return one of the following error codes, among others:
-
kAXErrorInvalidUIElementObserver - The observer is not a valid AXObserverRef type.
-
kAXErrorIllegalArgument - One or more of the arguments is an illegal value or the length of the notification name is greater than 1024.
-
kAXErrorNotificationUnsupported - The accessibility object does not support notifications (note that the system-wide accessibility object does not support notifications).
-
kAXErrorNotificationNotRegistered - This observer has not registered for any notifications.
-
kAXErrorCannotComplete - The function cannot complete because messaging has failed in some way.
-
kAXErrorFailure - There is some sort of system memory failure.
Sourcepub unsafe fn run_loop_source(&self) -> CFRetained<CFRunLoopSource>
pub unsafe fn run_loop_source(&self) -> CFRetained<CFRunLoopSource>
Returns the observer’s run loop source.
The observer must be added to a run loop before it can receive notifications. Note that releasing the AXObserverRef automatically removes the run loop source from the run loop (you can also do this explicitly by calling
//apple_ref/c/func/CFRunLoopRemoveSource CFRunLoopRemoveSource).
AXObserverGetRunLoopSource
might be used in code in this way:
CFRunLoopAddSource(CFRunLoopGetCurrent(), AXObserverGetRunLoopSource(observer), kCFRunLoopDefaultMode);
Parameter observer: The observer object (created from a call to
AXObserverCreate AXObserverCreate) for which to get the run loop source.
Returns: Returns the CFRunLoopSourceRef of the observer; NIL if you pass NIL in
observer
.
Methods from Deref<Target = CFType>§
Sourcepub fn downcast_ref<T>(&self) -> Option<&T>where
T: ConcreteType,
pub fn downcast_ref<T>(&self) -> Option<&T>where
T: ConcreteType,
Attempt to downcast the type to that of type T.
This is the reference-variant. Use CFRetained::downcast if you
want to convert a retained type. See also ConcreteType for more
details on which types support being converted to.
Sourcepub fn retain_count(&self) -> usize
pub fn retain_count(&self) -> usize
Get the reference count of the object.
This function may be useful for debugging. You normally do not use this function otherwise.
Beware that some things (like CFNumbers, small CFStrings etc.) may
not have a normal retain count for optimization purposes, and can
return usize::MAX in that case.
Trait Implementations§
Source§impl AsRef<AXObserver> for AXObserver
impl AsRef<AXObserver> for AXObserver
Source§impl AsRef<AnyObject> for AXObserver
impl AsRef<AnyObject> for AXObserver
Source§impl AsRef<CFType> for AXObserver
impl AsRef<CFType> for AXObserver
Source§impl Borrow<AnyObject> for AXObserver
impl Borrow<AnyObject> for AXObserver
Source§impl Borrow<CFType> for AXObserver
impl Borrow<CFType> for AXObserver
Source§impl ConcreteType for AXObserver
impl ConcreteType for AXObserver
Source§impl Debug for AXObserver
impl Debug for AXObserver
Source§impl Deref for AXObserver
impl Deref for AXObserver
Source§impl Hash for AXObserver
impl Hash for AXObserver
Source§impl Message for AXObserver
impl Message for AXObserver
Source§impl PartialEq for AXObserver
impl PartialEq for AXObserver
Source§impl RefEncode for AXObserver
impl RefEncode for AXObserver
Source§const ENCODING_REF: Encoding
const ENCODING_REF: Encoding
Source§impl Type for AXObserver
impl Type for AXObserver
Source§fn retain(&self) -> CFRetained<Self>where
Self: Sized,
fn retain(&self) -> CFRetained<Self>where
Self: Sized,
Source§fn as_concrete_TypeRef(&self) -> &Self
fn as_concrete_TypeRef(&self) -> &Self
this is redundant
core-foundation crate.Source§unsafe fn wrap_under_get_rule(ptr: *const Self) -> CFRetained<Self>where
Self: Sized,
unsafe fn wrap_under_get_rule(ptr: *const Self) -> CFRetained<Self>where
Self: Sized,
use CFRetained::retain
core-foundation crate. Read moreSource§fn as_CFTypeRef(&self) -> &CFType
fn as_CFTypeRef(&self) -> &CFType
this is redundant (CF types deref to CFType)
core-foundation crate.Source§unsafe fn wrap_under_create_rule(ptr: *const Self) -> CFRetained<Self>where
Self: Sized,
unsafe fn wrap_under_create_rule(ptr: *const Self) -> CFRetained<Self>where
Self: Sized,
use CFRetained::from_raw
core-foundation crate. Read more