Skip to content

Commit

Permalink
Fix doc issues
Browse files Browse the repository at this point in the history
  • Loading branch information
TTWNO committed May 24, 2024
1 parent ec98d6a commit 831afee
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 15 deletions.
14 changes: 8 additions & 6 deletions cache/src/convertable.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#[allow(async_fn_in_trait)]

Check failure on line 1 in cache/src/convertable.rs

View workflow job for this annotation

GitHub Actions / clippy

useless lint attribute

use atspi::Interface;
use atspi_proxies::{
accessible::AccessibleProxy, action::ActionProxy, application::ApplicationProxy,
Expand All @@ -13,39 +15,39 @@ use zbus::{proxy::ProxyImpl, CacheProperties, Error, Proxy, ProxyBuilder, ProxyD
pub trait Convertable<'a> {
type Error: std::error::Error;

/// Creates an [`Self::Accessible`] from the existing accessible item.
/// Creates an [`AccessibleProxy`] from the existing accessible item.
/// # Errors
///
/// This may fail based on the implementation of.
/// Generally, it fails if the accessible item does not implement to accessible interface.
/// This shouldn't be possible, but this function may fail for other reasons.
/// For example, to convert a [`zbus::Proxy`] into a [`Self::Accessible`], it may fail to create the new [`atspi_proxies::accessible::AccessibleProxy`].
/// For example, to convert a [`zbus::Proxy`] into a [`AccessibleProxy`], it may fail to create the new [`atspi_proxies::accessible::AccessibleProxy`].
fn to_accessible(
&self,
) -> impl Future<Output = Result<AccessibleProxy, Self::Error>> + Send;
/// Creates an [`Self::Action`] from the existing accessible item.
/// Creates an [`ActionProxy`] from the existing accessible item.
/// # Errors
///
/// This may fail based on the implementation.
/// Generally, it fails if the accessible item does not implement to action interface.
fn to_action(&self) -> impl Future<Output = Result<ActionProxy, Self::Error>> + Send;
/// Creates an [`Self::Application`] from the existing accessible item.
/// Creates an [`ApplicationProxy`] from the existing accessible item.
/// # Errors
///
/// This may fail based on the implementation.
/// Generally, it fails if the accessible item does not implement to application interface.
fn to_application(
&self,
) -> impl Future<Output = Result<ApplicationProxy, Self::Error>> + Send;
/// Creates an [`Collection`] from the existing accessible item.
/// Creates an [`CollectionProxy`] from the existing accessible item.
/// # Errors
///
/// This may fail based on the implementation.
/// it fails if the accessible item does not implement to collection interface.
fn to_collection(
&self,
) -> impl Future<Output = Result<CollectionProxy, Self::Error>> + Send;
/// Creates an [`Component`] from the existing accessible item.
/// Creates an [`ComponentProxy`] from the existing accessible item.
/// # Errors
///
/// This may fail based on the implementation.
Expand Down
18 changes: 9 additions & 9 deletions cache/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -312,7 +312,7 @@ impl CacheItem {
.collect(),
})
}
// Same as [`Accessible::get_children`], just offered as a non-async version.
// Same as [`AccessibleProxy::get_children`], just offered as a non-async version.
/// Get a `Vec` of children with the same type as `Self`.
/// # Errors
/// 1. Will return an `Err` variant if `self.cache` does not reference an active cache. This should never happen, but it is technically possible.
Expand Down Expand Up @@ -387,14 +387,14 @@ fn strong_cache(weak_cache: &Weak<Cache>) -> OdiliaResult<Arc<Cache>> {
}

impl CacheItem {
/// See [`atspi_proxies::accessible::Accessible::get_application`]
/// See [`atspi_proxies::accessible::AccessibleProxy::get_application`]
/// # Errors
/// - [`CacheError::NoItem`] if application is not in cache
pub fn get_application(&self) -> Result<Self, OdiliaError> {
let derefed_cache: Arc<Cache> = strong_cache(&self.cache)?;
derefed_cache.get(&self.app).ok_or(CacheError::NoItem.into())
}
/// See [`atspi_proxies::accessible::Accessible::parent`]
/// See [`atspi_proxies::accessible::AccessibleProxy::parent`]
/// # Errors
/// - [`CacheError::NoItem`] if application is not in cache
pub fn parent(&self) -> Result<Self, OdiliaError> {
Expand All @@ -404,31 +404,31 @@ impl CacheItem {
.or_else(|| self.cache.upgrade()?.get(&self.parent.key));
parent_item.ok_or(CacheError::NoItem.into())
}
/// See [`atspi_proxies::accessible::Accessible::get_attributes`]
/// See [`atspi_proxies::accessible::AccessibleProxy::get_attributes`]
/// # Errors
/// - If the item is no longer available over the AT-SPI connection.
pub async fn get_attributes(&self) -> Result<HashMap<String, String>, OdiliaError> {
Ok(as_accessible(self).await?.get_attributes().await?)
}
/// See [`atspi_proxies::accessible::Accessible::name`]
/// See [`atspi_proxies::accessible::AccessibleProxy::name`]
/// # Errors
/// - If the item is no longer available over the AT-SPI connection.
pub async fn name(&self) -> Result<String, OdiliaError> {
Ok(as_accessible(self).await?.name().await?)
}
/// See [`atspi_proxies::accessible::Accessible::locale`]
/// See [`atspi_proxies::accessible::AccessibleProxy::locale`]
/// # Errors
/// - If the item is no longer available over the AT-SPI connection.
pub async fn locale(&self) -> Result<String, OdiliaError> {
Ok(as_accessible(self).await?.locale().await?)
}
/// See [`atspi_proxies::accessible::Accessible::description`]
/// See [`atspi_proxies::accessible::AccessibleProxy::description`]
/// # Errors
/// - If the item is no longer available over the AT-SPI connection.
pub async fn description(&self) -> Result<String, OdiliaError> {
Ok(as_accessible(self).await?.description().await?)
}
/// See [`atspi_proxies::accessible::Accessible::get_realtion_set`]
/// See [`atspi_proxies::accessible::AccessibleProxy::get_relation_set`]
/// # Errors
/// - If the item is no longer available over the AT-SPI connection.
/// - The items mentioned are not in the cache.
Expand Down Expand Up @@ -459,7 +459,7 @@ impl CacheItem {
.map(|(relation, result_selfs)| Ok((relation, result_selfs?)))
.collect::<Result<Vec<(RelationType, Vec<Self>)>, OdiliaError>>()
}
/// See [`atspi_proxies::accessible::Accessible::get_child_at_index`]
/// See [`atspi_proxies::accessible::AccessibleProxy::get_child_at_index`]
/// # Errors
/// - The items mentioned are not in the cache.
pub fn get_child_at_index(&self, idx: i32) -> Result<Self, OdiliaError> {
Expand Down

0 comments on commit 831afee

Please sign in to comment.