1use async_trait::async_trait;
2use atspi_proxies::text::{Text, TextBlocking, TextProxy, TextProxyBlocking};
3
4impl_extended_errors!(TextProxy<'_>, TextExtError);
5impl_extended_errors!(TextProxyBlocking<'_>, TextBlockingExtError);
6
7#[allow(clippy::module_name_repetitions)]
8pub trait TextExtError: Text {
9 type Error: std::error::Error + From<<Self as Text>::Error> + Send + Sync;
10}
11
12#[allow(clippy::module_name_repetitions)]
13pub trait TextBlockingExtError: TextBlocking {
14 type Error: std::error::Error + From<<Self as TextBlocking>::Error>;
15}
16
17#[async_trait]
18pub trait TextExt: TextExtError {
19 async fn get_all_text(&self) -> Result<String, <Self as TextExtError>::Error>;
25}
26
27pub trait TextBlockingExt: TextBlockingExtError {
28 fn get_all_text(&self) -> Result<String, <Self as TextBlockingExtError>::Error>;
34}
35
36#[async_trait]
37impl<T: Text + TextExtError + Send + Sync> TextExt for T {
38 async fn get_all_text(&self) -> Result<String, <T as TextExtError>::Error> {
39 let length_of_string = self.character_count().await?;
40 Ok(self.get_text(0, length_of_string).await?)
41 }
42}
43
44impl<T: TextBlocking + TextBlockingExtError> TextBlockingExt for T {
45 fn get_all_text(&self) -> Result<String, <T as TextBlockingExtError>::Error> {
46 let length_of_string = self.character_count()?;
47 Ok(self.get_text(0, length_of_string)?)
48 }
49}
50
51assert_impl_all!(TextProxy: Text, TextExt);
52assert_impl_all!(TextProxyBlocking: TextBlocking, TextBlockingExt);