#[teloxide(transition)] -> #[teloxide(subtransition)]

This commit is contained in:
Temirkhan Myrzamadi 2020-07-27 00:52:03 +06:00
parent d43d74d80c
commit af2aa218e7
9 changed files with 17 additions and 17 deletions

View file

@ -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}`.

View file

@ -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<Dialogue> {
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,

View file

@ -7,7 +7,7 @@ pub struct ReceiveAgeState {
pub full_name: String,
}
#[teloxide(transition)]
#[teloxide(subtransition)]
async fn receive_age_state(
state: ReceiveAgeState,
cx: TransitionIn,

View file

@ -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,

View file

@ -8,7 +8,7 @@ pub struct ReceiveLocationState {
pub age: u8,
}
#[teloxide(transition)]
#[teloxide(subtransition)]
async fn receive_location(
state: ReceiveLocationState,
cx: TransitionIn,

View file

@ -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<Dialogue> {
cx.answer_str("Let's start! What's your full name?").await?;
next(ReceiveFullNameState)

View file

@ -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<Dialogue> {
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,

View file

@ -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<D>;
//!
//! #[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`].

View file

@ -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;
}