From af2aa218e7bfc442ab4475023a1c661834f576fc Mon Sep 17 00:00:00 2001 From: Temirkhan Myrzamadi Date: Mon, 27 Jul 2020 00:52:03 +0600 Subject: [PATCH] #[teloxide(transition)] -> #[teloxide(subtransition)] --- CHANGELOG.md | 2 +- README.md | 8 ++++---- .../dialogue_bot/src/dialogue/states/receive_age.rs | 2 +- .../src/dialogue/states/receive_full_name.rs | 2 +- .../src/dialogue/states/receive_location.rs | 2 +- examples/dialogue_bot/src/dialogue/states/start.rs | 2 +- examples/redis_remember_bot/src/transitions.rs | 4 ++-- src/dispatching/dialogue/mod.rs | 10 +++++----- src/dispatching/dialogue/transition.rs | 2 +- 9 files changed, 17 insertions(+), 17 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 831bdc47..4ae0124a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,7 +8,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Added - `BotBuilder`, which allows setting a default `ParseMode`. - The `Transition`, `Subtransition`, `SubtransitionOutputType` traits. - - A nicer approach to manage dialogues via `#[derive(Transition)]` + `#[teloxide(transition)]` (see `examples/dialogue_bot`). + - A nicer approach to manage dialogues via `#[derive(Transition)]` + `#[teloxide(subtransition)]` (see `examples/dialogue_bot`). ### Deprecated - `Bot::{from_env_with_client, new, with_client}`. diff --git a/README.md b/README.md index 47854d69..c0d3f6e1 100644 --- a/README.md +++ b/README.md @@ -208,7 +208,7 @@ impl Default for Dialogue { #[derive(Default)] pub struct StartState; -#[teloxide(transition)] +#[teloxide(subtransition)] async fn start(_state: StartState, cx: TransitionIn, _ans: String) -> TransitionOut { cx.answer_str("Let's start! What's your full name?").await?; next(ReceiveFullNameState) @@ -224,7 +224,7 @@ pub struct ReceiveAgeState { pub full_name: String, } -#[teloxide(transition)] +#[teloxide(subtransition)] async fn receive_age_state( state: ReceiveAgeState, cx: TransitionIn, @@ -250,7 +250,7 @@ async fn receive_age_state( #[derive(Generic)] pub struct ReceiveFullNameState; -#[teloxide(transition)] +#[teloxide(subtransition)] async fn receive_full_name( state: ReceiveFullNameState, cx: TransitionIn, @@ -271,7 +271,7 @@ pub struct ReceiveLocationState { pub age: u8, } -#[teloxide(transition)] +#[teloxide(subtransition)] async fn receive_location( state: ReceiveLocationState, cx: TransitionIn, diff --git a/examples/dialogue_bot/src/dialogue/states/receive_age.rs b/examples/dialogue_bot/src/dialogue/states/receive_age.rs index 71b31371..faa42bc7 100644 --- a/examples/dialogue_bot/src/dialogue/states/receive_age.rs +++ b/examples/dialogue_bot/src/dialogue/states/receive_age.rs @@ -7,7 +7,7 @@ pub struct ReceiveAgeState { pub full_name: String, } -#[teloxide(transition)] +#[teloxide(subtransition)] async fn receive_age_state( state: ReceiveAgeState, cx: TransitionIn, diff --git a/examples/dialogue_bot/src/dialogue/states/receive_full_name.rs b/examples/dialogue_bot/src/dialogue/states/receive_full_name.rs index 0d963d4e..85f19ad2 100644 --- a/examples/dialogue_bot/src/dialogue/states/receive_full_name.rs +++ b/examples/dialogue_bot/src/dialogue/states/receive_full_name.rs @@ -5,7 +5,7 @@ use teloxide_macros::teloxide; #[derive(Generic)] pub struct ReceiveFullNameState; -#[teloxide(transition)] +#[teloxide(subtransition)] async fn receive_full_name( state: ReceiveFullNameState, cx: TransitionIn, diff --git a/examples/dialogue_bot/src/dialogue/states/receive_location.rs b/examples/dialogue_bot/src/dialogue/states/receive_location.rs index 041219a2..d64f35f3 100644 --- a/examples/dialogue_bot/src/dialogue/states/receive_location.rs +++ b/examples/dialogue_bot/src/dialogue/states/receive_location.rs @@ -8,7 +8,7 @@ pub struct ReceiveLocationState { pub age: u8, } -#[teloxide(transition)] +#[teloxide(subtransition)] async fn receive_location( state: ReceiveLocationState, cx: TransitionIn, diff --git a/examples/dialogue_bot/src/dialogue/states/start.rs b/examples/dialogue_bot/src/dialogue/states/start.rs index 60240b59..32165233 100644 --- a/examples/dialogue_bot/src/dialogue/states/start.rs +++ b/examples/dialogue_bot/src/dialogue/states/start.rs @@ -5,7 +5,7 @@ use teloxide_macros::teloxide; #[derive(Default)] pub struct StartState; -#[teloxide(transition)] +#[teloxide(subtransition)] async fn start(_state: StartState, cx: TransitionIn, _ans: String) -> TransitionOut { cx.answer_str("Let's start! What's your full name?").await?; next(ReceiveFullNameState) diff --git a/examples/redis_remember_bot/src/transitions.rs b/examples/redis_remember_bot/src/transitions.rs index a35c94e8..dcc78db9 100644 --- a/examples/redis_remember_bot/src/transitions.rs +++ b/examples/redis_remember_bot/src/transitions.rs @@ -3,7 +3,7 @@ use teloxide_macros::teloxide; use super::states::*; -#[teloxide(transition)] +#[teloxide(subtransition)] async fn start(state: StartState, cx: TransitionIn, ans: String) -> TransitionOut { if let Ok(number) = ans.parse() { cx.answer_str(format!("Remembered number {}. Now use /get or /reset", number)).await?; @@ -14,7 +14,7 @@ async fn start(state: StartState, cx: TransitionIn, ans: String) -> TransitionOu } } -#[teloxide(transition)] +#[teloxide(subtransition)] async fn have_number( state: HaveNumberState, cx: TransitionIn, diff --git a/src/dispatching/dialogue/mod.rs b/src/dispatching/dialogue/mod.rs index 34b240d5..420a755b 100644 --- a/src/dispatching/dialogue/mod.rs +++ b/src/dispatching/dialogue/mod.rs @@ -26,7 +26,7 @@ //! //! To avoid boilerplate, teloxide exports these convenient things: the [`next`] //! and [`exit`] functions, and `#[derive(BotDialogue)]` with -//! `#[teloxide(transition)]`. Here's how your dialogues management code +//! `#[teloxide(subtransition)]`. Here's how your dialogues management code //! skeleton should look like: //! //! ```no_run @@ -41,17 +41,17 @@ //! //! type Out = TransitionOut; //! -//! #[teloxide(transition)] +//! #[teloxide(subtransition)] //! async fn _1_transition(_state: _1State, _cx: TransitionIn) -> Out { //! todo!() //! } //! -//! #[teloxide(transition)] +//! #[teloxide(subtransition)] //! async fn _2_transition(_state: _2State, _cx: TransitionIn) -> Out { //! todo!() //! } //! -//! #[teloxide(transition)] +//! #[teloxide(subtransition)] //! async fn _3_transition(_state: _3State, _cx: TransitionIn) -> Out { //! todo!() //! } @@ -99,7 +99,7 @@ //! } //! ``` //! -//! - `#[teloxide(transition)]` implements [`Subtransition`] for the first +//! - `#[teloxide(subtransition)]` implements [`Subtransition`] for the first //! argument of a function. //! - `#[derive(Transition)]` implements [`Transition`] for `D`, if all the //! variants implement [`Subtransition`]. diff --git a/src/dispatching/dialogue/transition.rs b/src/dispatching/dialogue/transition.rs index 56224b5c..d15ce303 100644 --- a/src/dispatching/dialogue/transition.rs +++ b/src/dispatching/dialogue/transition.rs @@ -38,7 +38,7 @@ where /// A type returned from a FSM subtransition function. /// -/// Now it is used only inside `#[teloxide(transition)]` for type inference. +/// Now it is used only inside `#[teloxide(subtransition)]` for type inference. pub trait SubtransitionOutputType { type Output; }