mirror of
https://github.com/teloxide/teloxide.git
synced 2024-12-22 22:46:39 +01:00
Start writing migration guide
This commit is contained in:
parent
de3429d082
commit
80a5865752
1 changed files with 53 additions and 0 deletions
|
@ -1,6 +1,59 @@
|
|||
This document describes breaking changes of `teloxide` crate, as well as the ways to update code.
|
||||
Note that the list of required changes is not fully exhaustive and it may lack something in rare cases.
|
||||
|
||||
## 0.10 -> 0.11
|
||||
|
||||
### core
|
||||
|
||||
Requests can now be `.await`ed directly, without need of `.send()` or `AutoSend`.
|
||||
If you previously used `AutoSend` adaptor, you can safely remove it.
|
||||
|
||||
`File`'s and `FileMeta`'s fields now don't have `file_` prefix.
|
||||
If you previously accessed the fields, you'll need to change remove the prefix:
|
||||
|
||||
```diff
|
||||
-_ = file.file_size;
|
||||
+_ = file.size;
|
||||
```
|
||||
|
||||
`Animation`, `Audio`, `Document`, `PassportFile`, `PhotoSize`, `Video`, `VideoNote` and `Voice` now contain `FileMeta` instead of its fields.
|
||||
Together with rename of `FileMeta`'s fields, you'll need to change `_` to `.`:
|
||||
|
||||
```diff
|
||||
-_ = animation.file_size;
|
||||
+_ = animation.file.size;
|
||||
```
|
||||
|
||||
Message id fields and parameters now use `MessageId` type, instead of `i32`.
|
||||
You may need to change code accordingly:
|
||||
|
||||
```diff
|
||||
-let id: i32 = message.id;
|
||||
+let id: MessageId = message.id;
|
||||
```
|
||||
```diff,rust
|
||||
let (cid, mid): (ChatId, i32) = get_message_to_delete_from_db();
|
||||
-bot.delete_message(cid, mid).await?;
|
||||
+bot.delete_message(cid, MessageId(mid)).await?;
|
||||
```
|
||||
|
||||
Note that at the same time `MessageId` is now a tuple struct.
|
||||
If you've accessed its only field you'll need to change it too:
|
||||
|
||||
```diff,rust
|
||||
-let MessageId { message_id } = bot.copy_message(dst_chat, src_chat, mid).await?;
|
||||
+let MessageId(message_id) = bot.copy_message(dst_chat, src_chat, mid).await?;
|
||||
save_to_db(message_id);
|
||||
```
|
||||
|
||||
Because of API updates `Sticker` type was refactored again.
|
||||
You may need to change code accordingly.
|
||||
See `Sticker` documentation for more information about the new structure.
|
||||
|
||||
### teloxide
|
||||
|
||||
<!-- TODO -->
|
||||
|
||||
## 0.9 -> 0.10
|
||||
|
||||
### core
|
||||
|
|
Loading…
Reference in a new issue