pub struct CacheItem {
pub object: AccessiblePrimitive,
pub app: AccessiblePrimitive,
pub parent: CacheRef,
pub index: i32,
pub children_num: i32,
pub interfaces: InterfaceSet,
pub role: Role,
pub states: StateSet,
pub text: String,
pub children: Vec<CacheRef>,
pub cache: Weak<Cache>,
}Expand description
A struct representing an accessible. To get any information from the cache other than the stored information like role, interfaces, and states, you will need to instantiate an atspi::accessible::AccessibleProxy or other *Proxy type from atspi to query further info.
Fields§
§object: AccessiblePrimitive§app: AccessiblePrimitive§parent: CacheRef§index: i32§children_num: i32§interfaces: InterfaceSet§role: Role§states: StateSet§text: String§children: Vec<CacheRef>§cache: Weak<Cache>Implementations§
Source§impl CacheItem
impl CacheItem
Sourcepub fn parent_ref(&mut self) -> OdiliaResult<Arc<RwLock<CacheItem>>>
pub fn parent_ref(&mut self) -> OdiliaResult<Arc<RwLock<CacheItem>>>
Return a reference to a parent. This is much cheaper than getting the parent element outright via Self::parent.
§Errors
This method will return a CacheError::NoItem if no item is found within the cache.
Sourcepub async fn from_atspi_event<T: Signified>(
event: &T,
cache: Weak<Cache>,
connection: &Connection,
) -> OdiliaResult<Self>
pub async fn from_atspi_event<T: Signified>( event: &T, cache: Weak<Cache>, connection: &Connection, ) -> OdiliaResult<Self>
Creates a CacheItem from an atspi::Event type.
§Errors
This can fail under three possible conditions:
- We are unable to convert information from the event into an
AccessiblePrimitivehashmap key. This should never happen. - We are unable to convert the
AccessiblePrimitiveto anatspi::accessible::AccessibleProxy. - The
accessible_to_cache_itemfunction fails for any reason. This also shouldn’t happen.
Sourcepub async fn from_atspi_cache_item(
atspi_cache_item: CacheItem,
cache: Weak<Cache>,
connection: &Connection,
) -> OdiliaResult<Self>
pub async fn from_atspi_cache_item( atspi_cache_item: CacheItem, cache: Weak<Cache>, connection: &Connection, ) -> OdiliaResult<Self>
Convert an atspi::cache::CacheItem into a crate::CacheItem.
This requires calls to DBus, which is quite expensive. Beware calling this too often.
§Errors
This function can fail under the following conditions:
- The
atspi::cache::CacheItemcan not be turned into acrate::AccessiblePrimitive. This should never happen. - The
crate::AccessiblePrimitivecan not be turned into aatspi::accessible::AccessibleProxy. This should never happen. - Getting children from the
AccessibleProxyfails. This should never happen.
The only time these can fail is if the item is removed on the application side before the conversion to AccessibleProxy.
Sourcepub fn get_children(&self) -> OdiliaResult<Vec<Self>>
pub fn get_children(&self) -> OdiliaResult<Vec<Self>>
Get a Vec of children with the same type as Self.
§Errors
- Will return an
Errvariant ifself.cachedoes not reference an active cache. This should never happen, but it is technically possible. - Any children keys’ values are not found in the cache itself.