pub struct AXObserver { /* private fields */ }AXUIElement 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 HIServices and AXError and libc only.
pub unsafe fn create( application: pid_t, callback: AXObserverCallback, out_observer: NonNull<*mut AXObserver>, ) -> AXError
HIServices and 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 HIServices and AXError and libc only.
pub unsafe fn create_with_info_callback( application: pid_t, callback: AXObserverCallbackWithInfo, out_observer: NonNull<*mut AXObserver>, ) -> AXError
HIServices and 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 features HIServices and AXError only.
pub unsafe fn add_notification( &self, element: &AXUIElement, notification: &CFString, refcon: *mut c_void, ) -> AXError
HIServices and 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 features HIServices and AXError only.
pub unsafe fn remove_notification( &self, element: &AXUIElement, notification: &CFString, ) -> AXError
HIServices and 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>
Available on crate feature HIServices only.
pub unsafe fn run_loop_source(&self) -> CFRetained<CFRunLoopSource>
HIServices only.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
Available on crate feature HIServices only.
impl AsRef<AXObserver> for AXObserver
HIServices only.Source§impl AsRef<AnyObject> for AXObserver
Available on crate feature HIServices only.
impl AsRef<AnyObject> for AXObserver
HIServices only.Source§impl AsRef<CFType> for AXObserver
Available on crate feature HIServices only.
impl AsRef<CFType> for AXObserver
HIServices only.Source§impl Borrow<AnyObject> for AXObserver
Available on crate feature HIServices only.
impl Borrow<AnyObject> for AXObserver
HIServices only.Source§impl Borrow<CFType> for AXObserver
Available on crate feature HIServices only.
impl Borrow<CFType> for AXObserver
HIServices only.Source§impl ConcreteType for AXObserver
Available on crate feature HIServices only.
impl ConcreteType for AXObserver
HIServices only.Source§impl Debug for AXObserver
Available on crate feature HIServices only.
impl Debug for AXObserver
HIServices only.Source§impl Deref for AXObserver
Available on crate feature HIServices only.
impl Deref for AXObserver
HIServices only.Source§impl Hash for AXObserver
Available on crate feature HIServices only.
impl Hash for AXObserver
HIServices only.Source§impl Message for AXObserver
Available on crate feature HIServices only.
impl Message for AXObserver
HIServices only.Source§impl PartialEq for AXObserver
Available on crate feature HIServices only.
impl PartialEq for AXObserver
HIServices only.Source§impl RefEncode for AXObserver
Available on crate feature HIServices only.
impl RefEncode for AXObserver
HIServices only.Source§const ENCODING_REF: Encoding
const ENCODING_REF: Encoding
Source§impl Type for AXObserver
Available on crate feature HIServices only.
impl Type for AXObserver
HIServices only.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
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,
core-foundation crate. Read moreSource§fn as_CFTypeRef(&self) -> &CFType
fn as_CFTypeRef(&self) -> &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,
core-foundation crate. Read moreimpl Eq for AXObserver
HIServices only.