pub struct Handler<'a, Output, Descr = Unspecified> { /* private fields */ }Expand description
An instance that receives an input and decides whether to break a chain or pass the value further.
In order to create this structure, you can use the predefined functions from
crate.
§The difference between chaining and branching
Handlers can be chained via Handler::chain and branched via
Handler::branch. To understand the difference between the two, consider
the following examples: a.chain(b).c and a.branch(b).c.
In a.chain(b).c, the handler a is given the rest of the handler chain,
b and c; if a decides to pass the value further, it invokes b. Then,
if b decides to pass the value further, it invokes c. Thus, the handler
chain is linear.
In a.branch(b).c, if a decides to pass the value further, it invokes
b. But since b is “branched”, it receives an empty chain, so it cannot
invoke c. Instead, if b decides to continue execution
(ControlFlow::Continue), a invokes c; otherwise
(ControlFlow::Break), the process is terminated. The handler chain is
nested.
To sum up, chaining looks like this:
a -> b -> cAnd branching looks like this:
a -> b
-> cThis is very crucial when b is a filter: if it is chained, it decides
whether or not to call c, but when it is branched, whether c is called
depends solely on a.
Implementations§
Source§impl<'a, Output, Descr> Handler<'a, Output, Descr>where
Output: 'a,
Descr: HandlerDescription,
impl<'a, Output, Descr> Handler<'a, Output, Descr>where
Output: 'a,
Descr: HandlerDescription,
Sourcepub fn chain(
self,
next: Handler<'a, Output, Descr>,
) -> Handler<'a, Output, Descr>
pub fn chain( self, next: Handler<'a, Output, Descr>, ) -> Handler<'a, Output, Descr>
Chain two handlers to form a chain of responsibility.
Chaining is different from branching. See “The difference between chaining and branching”.
This method makes use of HandlerSignature (stored in every handler)
to perform run-time type inference of the resulting handler
signature; this information is used by crate::type_check to make
sure that all required types are provided before execution.
§Examples
use dptree::prelude::*;
let handler: Handler<_> =
dptree::filter(|x: i32| x > 0).chain(dptree::endpoint(|| async { "done" }));
assert_eq!(handler.dispatch(dptree::deps![10]).await, ControlFlow::Break("done"));
assert_eq!(
handler.dispatch(dptree::deps![-10]).await,
ControlFlow::Continue(dptree::deps![-10])
);
Sourcepub fn branch(
self,
next: Handler<'a, Output, Descr>,
) -> Handler<'a, Output, Descr>where
Output: Send,
pub fn branch(
self,
next: Handler<'a, Output, Descr>,
) -> Handler<'a, Output, Descr>where
Output: Send,
Chain two handlers to make a tree of responsibility.
Chaining is different from branching. See “The difference between chaining and branching”.
This method makes use of HandlerSignature (stored in every handler)
to perform run-time type inference of the resulting handler
signature; this information is used by crate::type_check to make
sure that all required types are provided before execution.
§Examples
use dptree::prelude::*;
#[derive(Debug, PartialEq)]
enum Output {
Five,
One,
GT,
}
let dispatcher: Handler<_> = dptree::entry()
.branch(dptree::filter(|num: i32| num == 5).endpoint(|| async move { Output::Five }))
.branch(dptree::filter(|num: i32| num == 1).endpoint(|| async move { Output::One }))
.branch(dptree::filter(|num: i32| num > 2).endpoint(|| async move { Output::GT }));
assert_eq!(dispatcher.dispatch(dptree::deps![5]).await, ControlFlow::Break(Output::Five));
assert_eq!(dispatcher.dispatch(dptree::deps![1]).await, ControlFlow::Break(Output::One));
assert_eq!(dispatcher.dispatch(dptree::deps![3]).await, ControlFlow::Break(Output::GT));
assert_eq!(
dispatcher.dispatch(dptree::deps![0]).await,
ControlFlow::Continue(dptree::deps![0])
);Examples found in repository?
24async fn main() -> Result<(), Box<dyn Error>> {
25 pretty_env_logger::init();
26 log::info!("Starting buttons bot...");
27
28 let bot = Bot::from_env();
29
30 let handler = dptree::entry()
31 .branch(Update::filter_message().endpoint(message_handler))
32 .branch(Update::filter_callback_query().endpoint(callback_handler))
33 .branch(Update::filter_inline_query().endpoint(inline_query_handler));
34
35 Dispatcher::builder(bot, handler).enable_ctrlc_handler().build().dispatch().await;
36 Ok(())
37}More examples
40async fn main() {
41 pretty_env_logger::init();
42 log::info!("Starting deep linking bot...");
43
44 let bot = Bot::from_env();
45
46 let handler = dialogue::enter::<Update, InMemStorage<State>, State, _>()
47 .branch(
48 Update::filter_message()
49 .filter_command::<StartCommand>()
50 .branch(case![StartCommand::Start(start)].endpoint(start)),
51 )
52 .branch(
53 Update::filter_message()
54 .branch(case![State::WriteToSomeone { id }].endpoint(send_message)),
55 );
56
57 Dispatcher::builder(bot, handler)
58 .dependencies(deps![InMemStorage::<State>::new()])
59 .enable_ctrlc_handler()
60 .build()
61 .dispatch()
62 .await;
63}36async fn main() {
37 pretty_env_logger::init();
38 log::info!("Starting dialogue bot...");
39
40 let bot = Bot::from_env();
41
42 Dispatcher::builder(
43 bot,
44 Update::filter_message()
45 .enter_dialogue::<Message, InMemStorage<State>, State>()
46 .branch(dptree::case![State::Start].endpoint(start))
47 .branch(dptree::case![State::ReceiveFullName].endpoint(receive_full_name))
48 .branch(dptree::case![State::ReceiveAge { full_name }].endpoint(receive_age))
49 .branch(
50 dptree::case![State::ReceiveLocation { full_name, age }].endpoint(receive_location),
51 ),
52 )
53 .dependencies(dptree::deps![InMemStorage::<State>::new()])
54 .enable_ctrlc_handler()
55 .build()
56 .dispatch()
57 .await;
58}62fn schema() -> UpdateHandler<Box<dyn std::error::Error + Send + Sync + 'static>> {
63 use dptree::case;
64
65 let command_handler = ronami::filter_command::<Command, _>()
66 .branch(
67 case![State::Start]
68 .branch(case![Command::Help].endpoint(help))
69 .branch(case![Command::Start].endpoint(start)),
70 )
71 .branch(case![Command::Cancel].endpoint(cancel));
72
73 let message_handler = Update::filter_message()
74 .branch(command_handler)
75 .branch(case![State::ReceiveFullName].endpoint(receive_full_name))
76 .branch(dptree::endpoint(invalid_state));
77
78 let callback_query_handler = Update::filter_callback_query().branch(
79 case![State::ReceiveProductChoice { full_name }].endpoint(receive_product_selection),
80 );
81
82 dialogue::enter::<Update, InMemStorage<State>, State, _>()
83 .branch(message_handler)
84 .branch(callback_query_handler)
85}35async fn main() {
36 pretty_env_logger::init();
37 log::info!("Starting DB remember bot...");
38
39 let bot = Bot::from_env();
40
41 let storage: MyStorage = if std::env::var("DB_REMEMBER_REDIS").is_ok() {
42 RedisStorage::open("redis://127.0.0.1:6379", Bincode).await.unwrap().erase()
43 } else {
44 SqliteStorage::open("db.sqlite", Json).await.unwrap().erase()
45 };
46
47 let handler = Update::filter_message()
48 .enter_dialogue::<Message, ErasedStorage<State>, State>()
49 .branch(dptree::case![State::Start].endpoint(start))
50 .branch(
51 dptree::case![State::GotNumber(n)]
52 .branch(dptree::entry().filter_command::<Command>().endpoint(got_number))
53 .branch(dptree::endpoint(invalid_command)),
54 );
55
56 Dispatcher::builder(bot, handler)
57 .dependencies(dptree::deps![storage])
58 .enable_ctrlc_handler()
59 .build()
60 .dispatch()
61 .await;
62}16async fn main() -> ResponseResult<()> {
17 pretty_env_logger::init();
18
19 // We specify default parse mode to be `Html`, so that later we can use
20 // `html::user_mention`
21 let bot = ronami::Bot::from_env().parse_mode(ParseMode::Html);
22
23 // Create a handler for our bot, that will process updates from Telegram
24 let handler = dptree::entry()
25 .inspect(|u: Update| {
26 eprintln!("{u:#?}"); // Print the update to the console with inspect
27 })
28 .branch(
29 Update::filter_chat_member()
30 .branch(
31 dptree::filter(|m: ChatMemberUpdated| {
32 m.old_chat_member.is_left() && m.new_chat_member.is_present()
33 })
34 .endpoint(new_chat_member),
35 )
36 .branch(
37 dptree::filter(|m: ChatMemberUpdated| {
38 m.old_chat_member.is_present() && m.new_chat_member.is_left()
39 })
40 .endpoint(left_chat_member),
41 ),
42 );
43
44 // Create a dispatcher for our bot
45 Dispatcher::builder(bot, handler).enable_ctrlc_handler().build().dispatch().await;
46
47 Ok(())
48}Sourcepub async fn execute<Cont, ContFut>(
self,
input: DependencyMap,
cont: Cont,
) -> ControlFlow<Output, DependencyMap>where
Cont: FnOnce(DependencyMap) -> ContFut + Send + Sync + 'a,
ContFut: Future<Output = ControlFlow<Output, DependencyMap>> + Send + 'a,
pub async fn execute<Cont, ContFut>(
self,
input: DependencyMap,
cont: Cont,
) -> ControlFlow<Output, DependencyMap>where
Cont: FnOnce(DependencyMap) -> ContFut + Send + Sync + 'a,
ContFut: Future<Output = ControlFlow<Output, DependencyMap>> + Send + 'a,
Executes this handler with a continuation.
Usually, you do not want to call this method by yourself, if you do not
write your own handler implementation. If you wish to execute handler
without a continuation, take a look at the Handler::dispatch method.
NOTE: If you are using DependencyMap, you should first call
crate::type_check to type-check your handler against a container;
otherwise, type checking will be delayed until the actual execution,
which can make things harder to debug.
§Examples
use dptree::prelude::*;
let handler: Handler<_> = dptree::filter(|x: i32| x > 0);
let output = handler.execute(dptree::deps![10], |_| async { ControlFlow::Break("done") }).await;
assert_eq!(output, ControlFlow::Break("done"));
Sourcepub async fn dispatch(
&self,
input: DependencyMap,
) -> ControlFlow<Output, DependencyMap>
pub async fn dispatch( &self, input: DependencyMap, ) -> ControlFlow<Output, DependencyMap>
Executes this handler.
Returns ControlFlow::Break when executed successfully,
ControlFlow::Continue otherwise.
NOTE: If you are using DependencyMap, you should first call
crate::type_check to type-check your handler against a container;
otherwise, type checking will be delayed until the actual execution,
which can make things harder to debug.
Sourcepub fn description(&self) -> &Descr
pub fn description(&self) -> &Descr
Returns the set of updates that can be processed by this handler.
Sourcepub fn sig(&self) -> &HandlerSignature
pub fn sig(&self) -> &HandlerSignature
Returns this handler’s run-time type signature.
Source§impl<'a, Output, Descr> Handler<'a, Output, Descr>where
Output: 'a,
Descr: HandlerDescription,
impl<'a, Output, Descr> Handler<'a, Output, Descr>where
Output: 'a,
Descr: HandlerDescription,
Sourcepub fn filter<Pred, FnArgs>(self, pred: Pred) -> Handler<'a, Output, Descr>
pub fn filter<Pred, FnArgs>(self, pred: Pred) -> Handler<'a, Output, Descr>
Chain this handler with the filter predicate pred.
Examples found in repository?
6async fn main() {
7 pretty_env_logger::init();
8 log::info!("Starting middlewares_fallible bot...");
9
10 let bot = Bot::from_env();
11
12 let handler = Update::filter_message()
13 // Executes before the endpoint.
14 .inspect(|msg: Message| println!("Before (message #{}).", msg.id))
15 // Our "endpoint".
16 .map_async(my_endpoint)
17 // Executes after the endpoint. If the endpoint failed, print an error message and stop
18 // execution; if not, continue.
19 .filter(|result: HandlerResult, msg: Message| {
20 println!("In-between (message #{}).", msg.id);
21 match result {
22 Ok(()) => true,
23 Err(err) => {
24 eprintln!("Our endpoint failed: {err}");
25 false
26 }
27 }
28 })
29 // Executes only if the endpoint succeeded.
30 .endpoint(|msg: Message| async move {
31 println!("After (message #{}).", msg.id);
32 HandlerResult::Ok(())
33 });
34
35 Dispatcher::builder(bot, handler).enable_ctrlc_handler().build().dispatch().await;
36}Sourcepub fn filter_async<Pred, FnArgs>(
self,
pred: Pred,
) -> Handler<'a, Output, Descr>
pub fn filter_async<Pred, FnArgs>( self, pred: Pred, ) -> Handler<'a, Output, Descr>
Chain this handler with the async filter predicate pred.
Sourcepub fn filter_map<Proj, NewType, Args>(
self,
proj: Proj,
) -> Handler<'a, Output, Descr>
pub fn filter_map<Proj, NewType, Args>( self, proj: Proj, ) -> Handler<'a, Output, Descr>
Chain this handler with the filter projection proj.
Sourcepub fn filter_map_async<Proj, NewType, Args>(
self,
proj: Proj,
) -> Handler<'a, Output, Descr>
pub fn filter_map_async<Proj, NewType, Args>( self, proj: Proj, ) -> Handler<'a, Output, Descr>
Chain this handler with the async filter projection proj.
Sourcepub fn map<Proj, NewType, Args>(self, proj: Proj) -> Handler<'a, Output, Descr>
pub fn map<Proj, NewType, Args>(self, proj: Proj) -> Handler<'a, Output, Descr>
Chain this handler with the map projection proj.
Sourcepub fn map_async<Proj, NewType, Args>(
self,
proj: Proj,
) -> Handler<'a, Output, Descr>
pub fn map_async<Proj, NewType, Args>( self, proj: Proj, ) -> Handler<'a, Output, Descr>
Chain this handler with the async map projection proj.
Examples found in repository?
6async fn main() {
7 pretty_env_logger::init();
8 log::info!("Starting middlewares bot...");
9
10 let bot = Bot::from_env();
11
12 let handler = Update::filter_message()
13 // Executes before the endpoint.
14 .inspect(|msg: Message| println!("Before (message #{}).", msg.id))
15 // Our "endpoint".
16 .map_async(my_endpoint)
17 // Executes after the endpoint (even if it fails).
18 .inspect(|msg: Message| {
19 println!("After (message #{}).", msg.id);
20 })
21 // Retrieve the result of the endpoint and pass it to the dispatcher.
22 .endpoint(|result: HandlerResult| async move {
23 // Alternatively, we could also pattern-match on this value for more
24 // fine-grained behaviour.
25 result
26 });
27
28 Dispatcher::builder(bot, handler).enable_ctrlc_handler().build().dispatch().await;
29}More examples
6async fn main() {
7 pretty_env_logger::init();
8 log::info!("Starting middlewares_fallible bot...");
9
10 let bot = Bot::from_env();
11
12 let handler = Update::filter_message()
13 // Executes before the endpoint.
14 .inspect(|msg: Message| println!("Before (message #{}).", msg.id))
15 // Our "endpoint".
16 .map_async(my_endpoint)
17 // Executes after the endpoint. If the endpoint failed, print an error message and stop
18 // execution; if not, continue.
19 .filter(|result: HandlerResult, msg: Message| {
20 println!("In-between (message #{}).", msg.id);
21 match result {
22 Ok(()) => true,
23 Err(err) => {
24 eprintln!("Our endpoint failed: {err}");
25 false
26 }
27 }
28 })
29 // Executes only if the endpoint succeeded.
30 .endpoint(|msg: Message| async move {
31 println!("After (message #{}).", msg.id);
32 HandlerResult::Ok(())
33 });
34
35 Dispatcher::builder(bot, handler).enable_ctrlc_handler().build().dispatch().await;
36}Sourcepub fn inspect<F, Args>(self, f: F) -> Handler<'a, Output, Descr>
pub fn inspect<F, Args>(self, f: F) -> Handler<'a, Output, Descr>
Chain this handler with the inspection function f.
Examples found in repository?
6async fn main() {
7 pretty_env_logger::init();
8 log::info!("Starting middlewares bot...");
9
10 let bot = Bot::from_env();
11
12 let handler = Update::filter_message()
13 // Executes before the endpoint.
14 .inspect(|msg: Message| println!("Before (message #{}).", msg.id))
15 // Our "endpoint".
16 .map_async(my_endpoint)
17 // Executes after the endpoint (even if it fails).
18 .inspect(|msg: Message| {
19 println!("After (message #{}).", msg.id);
20 })
21 // Retrieve the result of the endpoint and pass it to the dispatcher.
22 .endpoint(|result: HandlerResult| async move {
23 // Alternatively, we could also pattern-match on this value for more
24 // fine-grained behaviour.
25 result
26 });
27
28 Dispatcher::builder(bot, handler).enable_ctrlc_handler().build().dispatch().await;
29}More examples
6async fn main() {
7 pretty_env_logger::init();
8 log::info!("Starting middlewares_fallible bot...");
9
10 let bot = Bot::from_env();
11
12 let handler = Update::filter_message()
13 // Executes before the endpoint.
14 .inspect(|msg: Message| println!("Before (message #{}).", msg.id))
15 // Our "endpoint".
16 .map_async(my_endpoint)
17 // Executes after the endpoint. If the endpoint failed, print an error message and stop
18 // execution; if not, continue.
19 .filter(|result: HandlerResult, msg: Message| {
20 println!("In-between (message #{}).", msg.id);
21 match result {
22 Ok(()) => true,
23 Err(err) => {
24 eprintln!("Our endpoint failed: {err}");
25 false
26 }
27 }
28 })
29 // Executes only if the endpoint succeeded.
30 .endpoint(|msg: Message| async move {
31 println!("After (message #{}).", msg.id);
32 HandlerResult::Ok(())
33 });
34
35 Dispatcher::builder(bot, handler).enable_ctrlc_handler().build().dispatch().await;
36}16async fn main() -> ResponseResult<()> {
17 pretty_env_logger::init();
18
19 // We specify default parse mode to be `Html`, so that later we can use
20 // `html::user_mention`
21 let bot = ronami::Bot::from_env().parse_mode(ParseMode::Html);
22
23 // Create a handler for our bot, that will process updates from Telegram
24 let handler = dptree::entry()
25 .inspect(|u: Update| {
26 eprintln!("{u:#?}"); // Print the update to the console with inspect
27 })
28 .branch(
29 Update::filter_chat_member()
30 .branch(
31 dptree::filter(|m: ChatMemberUpdated| {
32 m.old_chat_member.is_left() && m.new_chat_member.is_present()
33 })
34 .endpoint(new_chat_member),
35 )
36 .branch(
37 dptree::filter(|m: ChatMemberUpdated| {
38 m.old_chat_member.is_present() && m.new_chat_member.is_left()
39 })
40 .endpoint(left_chat_member),
41 ),
42 );
43
44 // Create a dispatcher for our bot
45 Dispatcher::builder(bot, handler).enable_ctrlc_handler().build().dispatch().await;
46
47 Ok(())
48}Sourcepub fn inspect_async<F, Args>(self, f: F) -> Handler<'a, Output, Descr>
pub fn inspect_async<F, Args>(self, f: F) -> Handler<'a, Output, Descr>
Chain this handler with the async inspection function f.
Sourcepub fn endpoint<F, FnArgs>(self, f: F) -> Handler<'a, Output, Descr>
pub fn endpoint<F, FnArgs>(self, f: F) -> Handler<'a, Output, Descr>
Chain this handler with the endpoint handler f.
Examples found in repository?
24async fn main() -> Result<(), Box<dyn Error>> {
25 pretty_env_logger::init();
26 log::info!("Starting buttons bot...");
27
28 let bot = Bot::from_env();
29
30 let handler = dptree::entry()
31 .branch(Update::filter_message().endpoint(message_handler))
32 .branch(Update::filter_callback_query().endpoint(callback_handler))
33 .branch(Update::filter_inline_query().endpoint(inline_query_handler));
34
35 Dispatcher::builder(bot, handler).enable_ctrlc_handler().build().dispatch().await;
36 Ok(())
37}More examples
40async fn main() {
41 pretty_env_logger::init();
42 log::info!("Starting deep linking bot...");
43
44 let bot = Bot::from_env();
45
46 let handler = dialogue::enter::<Update, InMemStorage<State>, State, _>()
47 .branch(
48 Update::filter_message()
49 .filter_command::<StartCommand>()
50 .branch(case![StartCommand::Start(start)].endpoint(start)),
51 )
52 .branch(
53 Update::filter_message()
54 .branch(case![State::WriteToSomeone { id }].endpoint(send_message)),
55 );
56
57 Dispatcher::builder(bot, handler)
58 .dependencies(deps![InMemStorage::<State>::new()])
59 .enable_ctrlc_handler()
60 .build()
61 .dispatch()
62 .await;
63}36async fn main() {
37 pretty_env_logger::init();
38 log::info!("Starting dialogue bot...");
39
40 let bot = Bot::from_env();
41
42 Dispatcher::builder(
43 bot,
44 Update::filter_message()
45 .enter_dialogue::<Message, InMemStorage<State>, State>()
46 .branch(dptree::case![State::Start].endpoint(start))
47 .branch(dptree::case![State::ReceiveFullName].endpoint(receive_full_name))
48 .branch(dptree::case![State::ReceiveAge { full_name }].endpoint(receive_age))
49 .branch(
50 dptree::case![State::ReceiveLocation { full_name, age }].endpoint(receive_location),
51 ),
52 )
53 .dependencies(dptree::deps![InMemStorage::<State>::new()])
54 .enable_ctrlc_handler()
55 .build()
56 .dispatch()
57 .await;
58}11async fn main() {
12 pretty_env_logger::init();
13 log::info!("Starting shared state bot...");
14
15 let bot = Bot::from_env();
16 let messages_total = Arc::new(AtomicU64::new(0));
17
18 let handler = Update::filter_message().endpoint(
19 |bot: Bot, messages_total: Arc<AtomicU64>, msg: Message| async move {
20 let previous = messages_total.fetch_add(1, Ordering::Relaxed);
21 bot.send_message(msg.chat.id, format!("I received {previous} messages in total."))
22 .await?;
23 respond(())
24 },
25 );
26
27 Dispatcher::builder(bot, handler)
28 // Pass the shared state to the handler as a dependency.
29 .dependencies(dptree::deps![messages_total])
30 .enable_ctrlc_handler()
31 .build()
32 .dispatch()
33 .await;
34}6async fn main() {
7 pretty_env_logger::init();
8 log::info!("Starting middlewares bot...");
9
10 let bot = Bot::from_env();
11
12 let handler = Update::filter_message()
13 // Executes before the endpoint.
14 .inspect(|msg: Message| println!("Before (message #{}).", msg.id))
15 // Our "endpoint".
16 .map_async(my_endpoint)
17 // Executes after the endpoint (even if it fails).
18 .inspect(|msg: Message| {
19 println!("After (message #{}).", msg.id);
20 })
21 // Retrieve the result of the endpoint and pass it to the dispatcher.
22 .endpoint(|result: HandlerResult| async move {
23 // Alternatively, we could also pattern-match on this value for more
24 // fine-grained behaviour.
25 result
26 });
27
28 Dispatcher::builder(bot, handler).enable_ctrlc_handler().build().dispatch().await;
29}62fn schema() -> UpdateHandler<Box<dyn std::error::Error + Send + Sync + 'static>> {
63 use dptree::case;
64
65 let command_handler = ronami::filter_command::<Command, _>()
66 .branch(
67 case![State::Start]
68 .branch(case![Command::Help].endpoint(help))
69 .branch(case![Command::Start].endpoint(start)),
70 )
71 .branch(case![Command::Cancel].endpoint(cancel));
72
73 let message_handler = Update::filter_message()
74 .branch(command_handler)
75 .branch(case![State::ReceiveFullName].endpoint(receive_full_name))
76 .branch(dptree::endpoint(invalid_state));
77
78 let callback_query_handler = Update::filter_callback_query().branch(
79 case![State::ReceiveProductChoice { full_name }].endpoint(receive_product_selection),
80 );
81
82 dialogue::enter::<Update, InMemStorage<State>, State, _>()
83 .branch(message_handler)
84 .branch(callback_query_handler)
85}Trait Implementations§
Source§impl<Output> HandlerExt<Output> for Handler<'static, Output, DpHandlerDescription>
impl<Output> HandlerExt<Output> for Handler<'static, Output, DpHandlerDescription>
Source§fn filter_command<C>(self) -> Self
fn filter_command<C>(self) -> Self
C. Read moreSource§fn filter_mention_command<C>(self) -> Self
fn filter_mention_command<C>(self) -> Self
C if the command
contains a bot mention, for example /start@my_bot. Read moreAuto Trait Implementations§
impl<'a, Output, Descr = Unspecified> !RefUnwindSafe for Handler<'a, Output, Descr>
impl<'a, Output, Descr = Unspecified> !UnwindSafe for Handler<'a, Output, Descr>
impl<'a, Output, Descr> Freeze for Handler<'a, Output, Descr>where
Arc<HandlerData<Descr, dyn Fn(DependencyMap, Box<dyn FnOnce(DependencyMap) -> Pin<Box<dyn Future<Output = ControlFlow<Output, DependencyMap>> + Send + 'a>> + Send + Sync + 'a>) -> Pin<Box<dyn Future<Output = ControlFlow<Output, DependencyMap>> + Send + 'a>> + Send + Sync + 'a>>: Freeze,
impl<'a, Output, Descr> Send for Handler<'a, Output, Descr>where
Arc<HandlerData<Descr, dyn Fn(DependencyMap, Box<dyn FnOnce(DependencyMap) -> Pin<Box<dyn Future<Output = ControlFlow<Output, DependencyMap>> + Send + 'a>> + Send + Sync + 'a>) -> Pin<Box<dyn Future<Output = ControlFlow<Output, DependencyMap>> + Send + 'a>> + Send + Sync + 'a>>: Send,
impl<'a, Output, Descr> Sync for Handler<'a, Output, Descr>where
Arc<HandlerData<Descr, dyn Fn(DependencyMap, Box<dyn FnOnce(DependencyMap) -> Pin<Box<dyn Future<Output = ControlFlow<Output, DependencyMap>> + Send + 'a>> + Send + Sync + 'a>) -> Pin<Box<dyn Future<Output = ControlFlow<Output, DependencyMap>> + Send + 'a>> + Send + Sync + 'a>>: Sync,
impl<'a, Output, Descr> Unpin for Handler<'a, Output, Descr>where
Arc<HandlerData<Descr, dyn Fn(DependencyMap, Box<dyn FnOnce(DependencyMap) -> Pin<Box<dyn Future<Output = ControlFlow<Output, DependencyMap>> + Send + 'a>> + Send + Sync + 'a>) -> Pin<Box<dyn Future<Output = ControlFlow<Output, DependencyMap>> + Send + 'a>> + Send + Sync + 'a>>: Unpin,
impl<'a, Output, Descr> UnsafeUnpin for Handler<'a, Output, Descr>where
Arc<HandlerData<Descr, dyn Fn(DependencyMap, Box<dyn FnOnce(DependencyMap) -> Pin<Box<dyn Future<Output = ControlFlow<Output, DependencyMap>> + Send + 'a>> + Send + Sync + 'a>) -> Pin<Box<dyn Future<Output = ControlFlow<Output, DependencyMap>> + Send + 'a>> + Send + Sync + 'a>>: UnsafeUnpin,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Erasable for T
impl<T> Erasable for T
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more