arci/traits/
speaker.rs

1use auto_impl::auto_impl;
2
3use crate::{error::Error, waits::WaitFuture};
4
5#[auto_impl(Box, Arc)]
6pub trait Speaker: Send + Sync {
7    /// Starts speaking and returns a future that waits until complete the speaking.
8    ///
9    /// # Implementation
10    ///
11    /// The returned future is expected to behave similarly to
12    /// [`std::thread::JoinHandle`] and [`tokio::task::JoinHandle`]:
13    ///
14    /// - Can wait for the operation to complete by `.await`.
15    /// - The operation does not end even if it is dropped.
16    ///
17    /// If the operation may block the current thread for an extended period of
18    /// time, consider [spawning a thread to running blocking
19    /// operations](https://docs.rs/tokio/1/tokio/index.html#cpu-bound-tasks-and-blocking-code).
20    fn speak(&self, message: &str) -> Result<WaitFuture, Error>;
21}