mirror of
https://github.com/teloxide/teloxide.git
synced 2024-12-22 14:35:36 +01:00
commit
716f3c131d
18 changed files with 47 additions and 47 deletions
4
.github/workflows/ci.yml
vendored
4
.github/workflows/ci.yml
vendored
|
@ -19,7 +19,7 @@ env:
|
|||
# When updating this, also update:
|
||||
# - crates/teloxide-core/src/codegen.rs
|
||||
# - rust-toolchain.toml
|
||||
rust_nightly: nightly-2023-05-28
|
||||
rust_nightly: nightly-2023-09-27
|
||||
# When updating this, also update:
|
||||
# - **/README.md
|
||||
# - **/src/lib.rs
|
||||
|
@ -84,7 +84,7 @@ jobs:
|
|||
toolchain: beta
|
||||
features: "--features full"
|
||||
- rust: nightly
|
||||
toolchain: nightly-2023-05-28
|
||||
toolchain: nightly-2023-09-27
|
||||
features: "--features full nightly"
|
||||
- rust: msrv
|
||||
toolchain: 1.65.0
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
[workspace]
|
||||
members = ["crates/*"]
|
||||
|
||||
resolver = "2"
|
||||
|
||||
# The settings below will be applied to all crates in the workspace
|
||||
[workspace.package]
|
||||
|
|
|
@ -155,18 +155,18 @@ pub(super) async fn worker<B>(
|
|||
//
|
||||
// Reasons (not to use `spawn_blocking`):
|
||||
//
|
||||
// 1. The work seems not very CPU-bound, it's not heavy computations,
|
||||
// it's more like light computations.
|
||||
// 1. The work seems not very CPU-bound, it's not heavy computations, it's more
|
||||
// like light computations.
|
||||
//
|
||||
// 2. `spawn_blocking` is not zero-cost — it spawns a new system thread
|
||||
// + do so other work. This may actually be *worse* then current
|
||||
// "just do everything in this async fn" approach.
|
||||
//
|
||||
// 3. With `rt-threaded` feature, tokio uses [`num_cpus()`] threads
|
||||
// which should be enough to work fine with one a-bit-blocking task.
|
||||
// Crucially current behaviour will be problem mostly with
|
||||
// single-threaded runtimes (and in case you're using one, you
|
||||
// probably don't want to spawn unnecessary threads anyway).
|
||||
// 3. With `rt-threaded` feature, tokio uses [`num_cpus()`] threads which should
|
||||
// be enough to work fine with one a-bit-blocking task. Crucially current
|
||||
// behaviour will be problem mostly with single-threaded runtimes (and in
|
||||
// case you're using one, you probably don't want to spawn unnecessary
|
||||
// threads anyway).
|
||||
//
|
||||
// I think if we'll ever change this behaviour, we need to make it
|
||||
// _configurable_.
|
||||
|
|
|
@ -23,7 +23,7 @@ use xshell::{cmd, Shell};
|
|||
|
||||
fn ensure_rustfmt(sh: &Shell) {
|
||||
// FIXME(waffle): find a better way to set toolchain
|
||||
let toolchain = "nightly-2023-05-28";
|
||||
let toolchain = "nightly-2023-09-27";
|
||||
|
||||
let version = cmd!(sh, "rustup run {toolchain} rustfmt --version").read().unwrap_or_default();
|
||||
|
||||
|
@ -36,7 +36,7 @@ fn ensure_rustfmt(sh: &Shell) {
|
|||
}
|
||||
|
||||
pub fn reformat(text: String) -> String {
|
||||
let toolchain = "nightly-2023-05-28";
|
||||
let toolchain = "nightly-2023-09-27";
|
||||
|
||||
let sh = Shell::new().unwrap();
|
||||
ensure_rustfmt(&sh);
|
||||
|
|
|
@ -1333,6 +1333,8 @@ macro_rules! requester_forward {
|
|||
}
|
||||
|
||||
#[test]
|
||||
// waffle: efficiency is not important here, and I don't want to rewrite this
|
||||
#[allow(clippy::format_collect)]
|
||||
fn codegen_requester_forward() {
|
||||
use crate::codegen::{
|
||||
add_hidden_preamble,
|
||||
|
|
|
@ -1,3 +1,6 @@
|
|||
// waffle: efficiency is not important here, and I don't want to rewrite this
|
||||
#![allow(clippy::format_collect)]
|
||||
|
||||
use std::{borrow::Borrow, collections::HashSet, ops::Deref};
|
||||
|
||||
use itertools::Itertools;
|
||||
|
@ -51,7 +54,7 @@ fn codegen_payloads() {
|
|||
|
||||
let multipart = multipart_input_file_fields(&method)
|
||||
.map(|field| format!(" @[multipart = {}]\n", field.join(", ")))
|
||||
.unwrap_or_else(String::new);
|
||||
.unwrap_or_default();
|
||||
|
||||
let derive = if !multipart.is_empty()
|
||||
|| matches!(
|
||||
|
|
|
@ -1337,6 +1337,8 @@ where
|
|||
// }
|
||||
|
||||
#[test]
|
||||
// waffle: efficiency is not important here, and I don't want to rewrite this
|
||||
#[allow(clippy::format_collect)]
|
||||
fn codegen_requester_methods() {
|
||||
use crate::codegen::{
|
||||
add_hidden_preamble,
|
||||
|
|
|
@ -315,7 +315,7 @@ pub(crate) mod serde_opt_date_from_unix_timestamp {
|
|||
}
|
||||
|
||||
{
|
||||
let json = r#"{}"#;
|
||||
let json = "{}";
|
||||
|
||||
let Struct { date } = serde_json::from_str(json).unwrap();
|
||||
assert_eq!(date, None);
|
||||
|
|
|
@ -203,8 +203,8 @@ impl PassportElementErrorReverseSide {
|
|||
}
|
||||
}
|
||||
|
||||
//// Represents an issue with the selfie with a document.
|
||||
//
|
||||
/// Represents an issue with the selfie with a document.
|
||||
///
|
||||
/// The error is considered resolved when the file with the selfie changes.
|
||||
///
|
||||
/// [The official docs](https://core.telegram.org/bots/api#passportelementerrorselfie).
|
||||
|
|
|
@ -31,7 +31,7 @@ mod tests {
|
|||
|
||||
#[test]
|
||||
fn chat_id_id_serialization() {
|
||||
let expected_json = String::from(r#"123456"#);
|
||||
let expected_json = String::from("123456");
|
||||
let actual_json = serde_json::to_string(&Recipient::Id(ChatId(123_456))).unwrap();
|
||||
|
||||
assert_eq!(expected_json, actual_json)
|
||||
|
|
|
@ -66,7 +66,7 @@ mod tests {
|
|||
|
||||
#[test]
|
||||
fn smoke_deser() {
|
||||
let json = r#"123"#;
|
||||
let json = "123";
|
||||
let mid: ThreadId = serde_json::from_str(json).unwrap();
|
||||
assert_eq!(mid, ThreadId(MessageId(123)));
|
||||
}
|
||||
|
@ -75,6 +75,6 @@ mod tests {
|
|||
fn smoke_ser() {
|
||||
let mid: ThreadId = ThreadId(MessageId(123));
|
||||
let json = serde_json::to_string(&mid).unwrap();
|
||||
assert_eq!(json, r#"123"#);
|
||||
assert_eq!(json, "123");
|
||||
}
|
||||
}
|
||||
|
|
|
@ -18,12 +18,12 @@ proc-macro = true
|
|||
|
||||
[dependencies]
|
||||
quote = "1.0.7"
|
||||
proc-macro2 = "1.0.19"
|
||||
proc-macro2 = "1.0.67"
|
||||
syn = { version = "1.0.13", features = ["full"] }
|
||||
heck = "0.4.0"
|
||||
|
||||
[package.metadata.release]
|
||||
tag-prefix = "macros-"
|
||||
pre-release-replacements = [
|
||||
{file="CHANGELOG.md", search="## unreleased", replace="## unreleased\n\n## {{version}} - {{date}}", exactly=1},
|
||||
{ file = "CHANGELOG.md", search = "## unreleased", replace = "## unreleased\n\n## {{version}} - {{date}}", exactly = 1 },
|
||||
]
|
||||
|
|
|
@ -19,10 +19,7 @@ pub(crate) fn fold_attrs<A, R>(
|
|||
.filter(|&a| filter(a))
|
||||
.flat_map(|attribute| {
|
||||
let Some(key) = attribute.path.get_ident().cloned() else {
|
||||
return vec![Err(compile_error_at(
|
||||
"expected an ident",
|
||||
attribute.path.span(),
|
||||
))];
|
||||
return vec![Err(compile_error_at("expected an ident", attribute.path.span()))];
|
||||
};
|
||||
|
||||
match (|input: ParseStream<'_>| Attrs::parse_with_key(input, key))
|
||||
|
|
|
@ -145,12 +145,11 @@ impl CommandAttr {
|
|||
}
|
||||
|
||||
"command" => {
|
||||
let Some(attr) = key.pop()
|
||||
else {
|
||||
let Some(attr) = key.pop() else {
|
||||
return Err(compile_error_at(
|
||||
"expected an attribute name",
|
||||
outermost_key.span(),
|
||||
))
|
||||
));
|
||||
};
|
||||
|
||||
if let Some(unexpected_key) = key.last() {
|
||||
|
|
|
@ -42,12 +42,12 @@ impl<S> SqliteStorage<S> {
|
|||
let pool = SqlitePool::connect(format!("sqlite:{path}?mode=rwc").as_str()).await?;
|
||||
let mut conn = pool.acquire().await?;
|
||||
sqlx::query(
|
||||
r#"
|
||||
"
|
||||
CREATE TABLE IF NOT EXISTS teloxide_dialogues (
|
||||
chat_id BIGINT PRIMARY KEY,
|
||||
dialogue BLOB NOT NULL
|
||||
);
|
||||
"#,
|
||||
",
|
||||
)
|
||||
.execute(&mut conn)
|
||||
.await?;
|
||||
|
@ -98,10 +98,10 @@ where
|
|||
.await?
|
||||
.execute(
|
||||
sqlx::query(
|
||||
r#"
|
||||
"
|
||||
INSERT INTO teloxide_dialogues VALUES (?, ?)
|
||||
ON CONFLICT(chat_id) DO UPDATE SET dialogue=excluded.dialogue
|
||||
"#,
|
||||
",
|
||||
)
|
||||
.bind(chat_id)
|
||||
.bind(d),
|
||||
|
|
|
@ -165,9 +165,9 @@ where
|
|||
/// the [`Requester`] trait.
|
||||
/// 2. `handler` is an `async` function that takes arguments from
|
||||
/// [`DependencyMap`] (see below) and returns [`ResponseResult`].
|
||||
/// 3. `cmd` is a type hint for your command enumeration
|
||||
/// `MyCommand`: just write `MyCommand::ty()`. Note that `MyCommand` must
|
||||
/// implement the [`BotCommands`] trait, typically via
|
||||
/// 3. `cmd` is a type hint for your command enumeration `MyCommand`: just write
|
||||
/// `MyCommand::ty()`. Note that `MyCommand` must implement the
|
||||
/// [`BotCommands`] trait, typically via
|
||||
/// `#[derive(BotCommands)]`.
|
||||
///
|
||||
/// All the other requirements are about thread safety and data validity and can
|
||||
|
@ -236,8 +236,8 @@ where
|
|||
/// [`DependencyMap`] (see below) and returns [`ResponseResult`].
|
||||
/// 3. `listener` is something that takes updates from a Telegram server and
|
||||
/// implements [`UpdateListener`].
|
||||
/// 4. `cmd` is a type hint for your command enumeration `MyCommand`: just
|
||||
/// write `MyCommand::ty()`. Note that `MyCommand` must implement the
|
||||
/// 4. `cmd` is a type hint for your command enumeration `MyCommand`: just write
|
||||
/// `MyCommand::ty()`. Note that `MyCommand` must implement the
|
||||
/// [`BotCommands`] trait, typically via `#[derive(BotCommands)]`.
|
||||
///
|
||||
/// All the other requirements are about thread safety and data validity and can
|
||||
|
|
|
@ -283,9 +283,6 @@ mod tests {
|
|||
is_premium: false,
|
||||
added_to_attachment_menu: false,
|
||||
};
|
||||
assert_eq!(
|
||||
user_mention_or_link(&user_without_username),
|
||||
r#"[Name](tg://user/?id=123456789)"#
|
||||
)
|
||||
assert_eq!(user_mention_or_link(&user_without_username), "[Name](tg://user/?id=123456789)")
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
[toolchain]
|
||||
channel = "nightly-2023-05-28"
|
||||
channel = "nightly-2023-09-27"
|
||||
components = ["rustfmt", "clippy"]
|
||||
profile = "minimal"
|
||||
|
|
Loading…
Reference in a new issue