From 4314a24e78aab610b0487a424b75693f08722227 Mon Sep 17 00:00:00 2001 From: Joscha Date: Wed, 4 Dec 2024 17:08:52 +0100 Subject: [PATCH 01/15] Switch to jiff from time --- CHANGELOG.md | 4 ++++ Cargo.toml | 2 +- examples/testbot_commands.rs | 8 +++---- examples/testbot_instance.rs | 43 ++++++----------------------------- examples/testbot_instances.rs | 43 ++++++----------------------------- examples/testbot_manual.rs | 43 ++++++----------------------------- src/api/types.rs | 12 ++++------ src/bot/botrulez/uptime.rs | 23 ++++++++----------- src/conn.rs | 14 ++++++------ 9 files changed, 51 insertions(+), 141 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 1464ea7..287c658 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -14,6 +14,10 @@ Procedure when bumping the version number: ## Unreleased +### Changed + +- **(breaking)** Switched to `jiff` from `time` + ## v0.5.1 - 2024-05-20 ### Added diff --git a/Cargo.toml b/Cargo.toml index fb59b0d..2d45180 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -11,10 +11,10 @@ async-trait = { version = "0.1.80", optional = true } caseless = "0.2.1" cookie = { version = "0.18.1", optional = true } futures-util = { version = "0.3.30", default-features = false, features = ["sink"] } +jiff = { version = "0.1.15", features = ["serde"] } log = "0.4.21" serde = { version = "1.0.202", features = ["derive"] } serde_json = "1.0.117" -time = { version = "0.3.36", features = ["serde"] } tokio = { version = "1.37.0", features = ["time", "sync", "macros", "rt"] } tokio-stream = "0.1.15" tokio-tungstenite = { version = "0.21.0", features = ["rustls-tls-native-roots"] } diff --git a/examples/testbot_commands.rs b/examples/testbot_commands.rs index 3a07c19..bacab89 100644 --- a/examples/testbot_commands.rs +++ b/examples/testbot_commands.rs @@ -12,8 +12,8 @@ use euphoxide::bot::commands::Commands; use euphoxide::bot::instance::{Event, ServerConfig}; use euphoxide::bot::instances::Instances; use euphoxide::conn; +use jiff::Timestamp; use log::error; -use time::OffsetDateTime; use tokio::sync::mpsc; const HELP: &str = "I'm an example bot for https://github.com/Garmelon/euphoxide"; @@ -74,7 +74,7 @@ impl ClapCommand for Test { struct Bot { commands: Arc>, - start_time: OffsetDateTime, + start_time: Timestamp, stop: bool, } @@ -85,7 +85,7 @@ impl HasDescriptions for Bot { } impl HasStartTime for Bot { - fn start_time(&self) -> OffsetDateTime { + fn start_time(&self) -> Timestamp { self.start_time } } @@ -107,7 +107,7 @@ async fn main() { let mut bot = Bot { commands: cmds.clone(), - start_time: OffsetDateTime::now_utc(), + start_time: Timestamp::now(), stop: false, }; diff --git a/examples/testbot_instance.rs b/examples/testbot_instance.rs index 5b932b3..c1c2895 100644 --- a/examples/testbot_instance.rs +++ b/examples/testbot_instance.rs @@ -3,46 +3,14 @@ use euphoxide::api::packet::ParsedPacket; use euphoxide::api::{Data, Nick, Send}; +use euphoxide::bot::botrulez; use euphoxide::bot::instance::{ConnSnapshot, Event, ServerConfig}; -use time::OffsetDateTime; +use jiff::Timestamp; use tokio::sync::mpsc; const NICK: &str = "TestBot"; const HELP: &str = "I'm an example bot for https://github.com/Garmelon/euphoxide"; -fn format_delta(delta: time::Duration) -> String { - const MINUTE: u64 = 60; - const HOUR: u64 = MINUTE * 60; - const DAY: u64 = HOUR * 24; - - let mut seconds: u64 = delta.whole_seconds().try_into().unwrap(); - let mut parts = vec![]; - - let days = seconds / DAY; - if days > 0 { - parts.push(format!("{days}d")); - seconds -= days * DAY; - } - - let hours = seconds / HOUR; - if hours > 0 { - parts.push(format!("{hours}h")); - seconds -= hours * HOUR; - } - - let mins = seconds / MINUTE; - if mins > 0 { - parts.push(format!("{mins}m")); - seconds -= mins * MINUTE; - } - - if parts.is_empty() || seconds > 0 { - parts.push(format!("{seconds}s")); - } - - parts.join(" ") -} - async fn on_packet(packet: ParsedPacket, snapshot: ConnSnapshot) -> Result<(), ()> { let data = match packet.content { Ok(data) => data, @@ -107,8 +75,11 @@ async fn on_packet(packet: ParsedPacket, snapshot: ConnSnapshot) -> Result<(), ( reply = Some(HELP.to_string()); } else if content == format!("!uptime @{NICK}") { if let Some(joined) = snapshot.state.joined() { - let delta = OffsetDateTime::now_utc() - joined.since; - reply = Some(format!("/me has been up for {}", format_delta(delta))); + let delta = Timestamp::now() - joined.since; + reply = Some(format!( + "/me has been up for {}", + botrulez::format_duration(delta) + )); } } else if content == "!test" { reply = Some("Test successful!".to_string()); diff --git a/examples/testbot_instances.rs b/examples/testbot_instances.rs index a8a6848..d44cbe7 100644 --- a/examples/testbot_instances.rs +++ b/examples/testbot_instances.rs @@ -3,47 +3,15 @@ use euphoxide::api::packet::ParsedPacket; use euphoxide::api::{Data, Nick, Send}; +use euphoxide::bot::botrulez; use euphoxide::bot::instance::{ConnSnapshot, Event, ServerConfig}; use euphoxide::bot::instances::Instances; -use time::OffsetDateTime; +use jiff::Timestamp; use tokio::sync::mpsc; const NICK: &str = "TestBot"; const HELP: &str = "I'm an example bot for https://github.com/Garmelon/euphoxide"; -fn format_delta(delta: time::Duration) -> String { - const MINUTE: u64 = 60; - const HOUR: u64 = MINUTE * 60; - const DAY: u64 = HOUR * 24; - - let mut seconds: u64 = delta.whole_seconds().try_into().unwrap(); - let mut parts = vec![]; - - let days = seconds / DAY; - if days > 0 { - parts.push(format!("{days}d")); - seconds -= days * DAY; - } - - let hours = seconds / HOUR; - if hours > 0 { - parts.push(format!("{hours}h")); - seconds -= hours * HOUR; - } - - let mins = seconds / MINUTE; - if mins > 0 { - parts.push(format!("{mins}m")); - seconds -= mins * MINUTE; - } - - if parts.is_empty() || seconds > 0 { - parts.push(format!("{seconds}s")); - } - - parts.join(" ") -} - async fn on_packet(packet: ParsedPacket, snapshot: ConnSnapshot) -> Result<(), ()> { let data = match packet.content { Ok(data) => data, @@ -108,8 +76,11 @@ async fn on_packet(packet: ParsedPacket, snapshot: ConnSnapshot) -> Result<(), ( reply = Some(HELP.to_string()); } else if content == format!("!uptime @{NICK}") { if let Some(joined) = snapshot.state.joined() { - let delta = OffsetDateTime::now_utc() - joined.since; - reply = Some(format!("/me has been up for {}", format_delta(delta))); + let delta = Timestamp::now() - joined.since; + reply = Some(format!( + "/me has been up for {}", + botrulez::format_duration(delta) + )); } } else if content == "!test" { reply = Some("Test successful!".to_string()); diff --git a/examples/testbot_manual.rs b/examples/testbot_manual.rs index c059004..d6535a4 100644 --- a/examples/testbot_manual.rs +++ b/examples/testbot_manual.rs @@ -6,8 +6,9 @@ use std::time::Duration; use euphoxide::api::packet::ParsedPacket; use euphoxide::api::{Data, Nick, Send}; +use euphoxide::bot::botrulez; use euphoxide::conn::{Conn, ConnTx, State}; -use time::OffsetDateTime; +use jiff::Timestamp; const TIMEOUT: Duration = Duration::from_secs(10); const DOMAIN: &str = "euphoria.leet.nu"; @@ -15,39 +16,6 @@ const ROOM: &str = "test"; const NICK: &str = "TestBot"; const HELP: &str = "I'm an example bot for https://github.com/Garmelon/euphoxide"; -fn format_delta(delta: time::Duration) -> String { - const MINUTE: u64 = 60; - const HOUR: u64 = MINUTE * 60; - const DAY: u64 = HOUR * 24; - - let mut seconds: u64 = delta.whole_seconds().try_into().unwrap(); - let mut parts = vec![]; - - let days = seconds / DAY; - if days > 0 { - parts.push(format!("{days}d")); - seconds -= days * DAY; - } - - let hours = seconds / HOUR; - if hours > 0 { - parts.push(format!("{hours}h")); - seconds -= hours * HOUR; - } - - let mins = seconds / MINUTE; - if mins > 0 { - parts.push(format!("{mins}m")); - seconds -= mins * MINUTE; - } - - if parts.is_empty() || seconds > 0 { - parts.push(format!("{seconds}s")); - } - - parts.join(" ") -} - async fn on_packet(packet: ParsedPacket, conn_tx: &ConnTx, state: &State) -> Result<(), ()> { let data = match packet.content { Ok(data) => data, @@ -112,8 +80,11 @@ async fn on_packet(packet: ParsedPacket, conn_tx: &ConnTx, state: &State) -> Res reply = Some(HELP.to_string()); } else if content == format!("!uptime @{NICK}") { if let Some(joined) = state.joined() { - let delta = OffsetDateTime::now_utc() - joined.since; - reply = Some(format!("/me has been up for {}", format_delta(delta))); + let delta = Timestamp::now() - joined.since; + reply = Some(format!( + "/me has been up for {}", + botrulez::format_duration(delta) + )); } } else if content == "!test" { reply = Some("Test successful!".to_string()); diff --git a/src/api/types.rs b/src/api/types.rs index d1a393d..8f438e9 100644 --- a/src/api/types.rs +++ b/src/api/types.rs @@ -10,9 +10,9 @@ use std::num::ParseIntError; use std::str::FromStr; use std::{error, fmt}; +use jiff::Timestamp; use serde::{de, ser, Deserialize, Serialize}; use serde_json::Value; -use time::{OffsetDateTime, UtcOffset}; /// Describes an account and its preferred name. #[derive(Debug, Clone, Serialize, Deserialize)] @@ -403,19 +403,15 @@ impl<'de> Deserialize<'de> for Snowflake { /// Time is specified as a signed 64-bit integer, giving the number of seconds /// since the Unix Epoch. #[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)] -pub struct Time(#[serde(with = "time::serde::timestamp")] pub OffsetDateTime); +pub struct Time(#[serde(with = "jiff::fmt::serde::timestamp::second::required")] pub Timestamp); impl Time { - pub fn new(time: OffsetDateTime) -> Self { - let time = time - .to_offset(UtcOffset::UTC) - .replace_millisecond(0) - .unwrap(); + pub fn new(time: Timestamp) -> Self { Self(time) } pub fn now() -> Self { - Self::new(OffsetDateTime::now_utc()) + Self::new(Timestamp::now()) } } diff --git a/src/bot/botrulez/uptime.rs b/src/bot/botrulez/uptime.rs index b4465e5..1c98ff6 100644 --- a/src/bot/botrulez/uptime.rs +++ b/src/bot/botrulez/uptime.rs @@ -1,24 +1,21 @@ use async_trait::async_trait; use clap::Parser; -use time::macros::format_description; -use time::{Duration, OffsetDateTime, UtcOffset}; +use jiff::{Span, Timestamp}; use crate::api::Message; use crate::bot::command::{ClapCommand, Command, Context}; use crate::conn; -pub fn format_time(t: OffsetDateTime) -> String { - let t = t.to_offset(UtcOffset::UTC); - let format = format_description!("[year]-[month]-[day] [hour]:[minute]:[second] UTC"); - t.format(format).unwrap() +pub fn format_time(t: Timestamp) -> String { + t.strftime("%Y-&m-%d %H:%M:%S UTC").to_string() } -pub fn format_duration(d: Duration) -> String { +pub fn format_duration(d: Span) -> String { let d_abs = d.abs(); - let days = d_abs.whole_days(); - let hours = d_abs.whole_hours() % 24; - let mins = d_abs.whole_minutes() % 60; - let secs = d_abs.whole_seconds() % 60; + let days = d_abs.get_days(); + let hours = d_abs.get_hours() % 24; + let mins = d_abs.get_minutes() % 60; + let secs = d_abs.get_seconds() % 60; let mut segments = vec![]; if days > 0 { @@ -48,13 +45,13 @@ pub fn format_duration(d: Duration) -> String { pub struct Uptime; pub trait HasStartTime { - fn start_time(&self) -> OffsetDateTime; + fn start_time(&self) -> Timestamp; } impl Uptime { fn formulate_reply(&self, ctx: &Context, bot: &B, connected: bool) -> String { let start = bot.start_time(); - let now = OffsetDateTime::now_utc(); + let now = Timestamp::now(); let mut reply = format!( "/me has been up since {} ({})", diff --git a/src/conn.rs b/src/conn.rs index 92d083c..8d6820c 100644 --- a/src/conn.rs +++ b/src/conn.rs @@ -6,8 +6,8 @@ use std::future::Future; use std::time::{Duration, Instant}; use std::{error, fmt, result}; -use ::time::OffsetDateTime; use futures_util::SinkExt; +use jiff::Timestamp; use log::debug; use tokio::net::TcpStream; use tokio::select; @@ -75,7 +75,7 @@ pub type Result = result::Result; #[derive(Debug, Clone)] pub struct Joining { - pub since: OffsetDateTime, + pub since: Timestamp, pub hello: Option, pub snapshot: Option, pub bounce: Option, @@ -84,7 +84,7 @@ pub struct Joining { impl Joining { fn new() -> Self { Self { - since: OffsetDateTime::now_utc(), + since: Timestamp::now(), hello: None, snapshot: None, bounce: None, @@ -122,7 +122,7 @@ impl Joining { .map(|s| (s.session_id.clone(), SessionInfo::Full(s))) .collect::>(); Some(Joined { - since: OffsetDateTime::now_utc(), + since: Timestamp::now(), session, account: hello.account.clone(), listing, @@ -164,7 +164,7 @@ impl SessionInfo { #[derive(Debug, Clone)] pub struct Joined { - pub since: OffsetDateTime, + pub since: Timestamp, pub session: SessionView, pub account: Option, pub listing: HashMap, @@ -522,10 +522,10 @@ impl Conn { self.disconnect().await?; } - let now = OffsetDateTime::now_utc(); + let now = Timestamp::now(); // Send new ws ping - let ws_payload = now.unix_timestamp_nanos().to_be_bytes().to_vec(); + let ws_payload = now.as_millisecond().to_be_bytes().to_vec(); self.last_ws_ping_payload = Some(ws_payload.clone()); self.last_ws_ping_replied_to = false; self.ws.send(tungstenite::Message::Ping(ws_payload)).await?; From 85c93ee01d7645f391cd284767f26f56a069efe3 Mon Sep 17 00:00:00 2001 From: Joscha Date: Wed, 4 Dec 2024 17:10:42 +0100 Subject: [PATCH 02/15] Update dependencies --- Cargo.toml | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 2d45180..3a44b76 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -7,27 +7,27 @@ edition = "2021" bot = ["dep:async-trait", "dep:clap", "dep:cookie"] [dependencies] -async-trait = { version = "0.1.80", optional = true } +async-trait = { version = "0.1.83", optional = true } caseless = "0.2.1" cookie = { version = "0.18.1", optional = true } -futures-util = { version = "0.3.30", default-features = false, features = ["sink"] } +futures-util = { version = "0.3.31", default-features = false, features = ["sink"] } jiff = { version = "0.1.15", features = ["serde"] } -log = "0.4.21" -serde = { version = "1.0.202", features = ["derive"] } -serde_json = "1.0.117" -tokio = { version = "1.37.0", features = ["time", "sync", "macros", "rt"] } -tokio-stream = "0.1.15" -tokio-tungstenite = { version = "0.21.0", features = ["rustls-tls-native-roots"] } -unicode-normalization = "0.1.23" +log = "0.4.22" +serde = { version = "1.0.215", features = ["derive"] } +serde_json = "1.0.133" +tokio = { version = "1.42.0", features = ["time", "sync", "macros", "rt"] } +tokio-stream = "0.1.16" +tokio-tungstenite = { version = "0.24.0", features = ["rustls-tls-native-roots"] } +unicode-normalization = "0.1.24" [dependencies.clap] -version = "4.5.4" +version = "4.5.22" optional = true default-features = false features = ["std", "derive", "deprecated"] [dev-dependencies] # For example bot -tokio = { version = "1.37.0", features = ["rt-multi-thread"] } +tokio = { version = "1.42.0", features = ["rt-multi-thread"] } [[example]] name = "testbot_instance" From 8506a231dd076358dd0ae0c51b93907060333c62 Mon Sep 17 00:00:00 2001 From: Joscha Date: Wed, 4 Dec 2024 17:14:15 +0100 Subject: [PATCH 03/15] Add more lints --- Cargo.toml | 22 ++++++++++++++++++++++ examples/testbot_commands.rs | 2 ++ examples/testbot_instance.rs | 1 + examples/testbot_instances.rs | 1 + examples/testbot_manual.rs | 1 + src/lib.rs | 11 ----------- 6 files changed, 27 insertions(+), 11 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 3a44b76..917f0b4 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -40,3 +40,25 @@ required-features = ["bot"] [[example]] name = "testbot_commands" required-features = ["bot"] + +[lints] +rust.unsafe_code = { level = "forbid", priority = 1 } +# Lint groups +rust.deprecated_safe = "warn" +rust.future_incompatible = "warn" +rust.keyword_idents = "warn" +rust.rust_2018_idioms = "warn" +rust.unused = "warn" +# Individual lints +rust.non_local_definitions = "warn" +rust.redundant_imports = "warn" +rust.redundant_lifetimes = "warn" +rust.single_use_lifetimes = "warn" +rust.unit_bindings = "warn" +rust.unnameable_types = "warn" +rust.unused_crate_dependencies = "warn" +rust.unused_import_braces = "warn" +rust.unused_lifetimes = "warn" +rust.unused_qualifications = "warn" +# Clippy +clippy.use_self = "warn" diff --git a/examples/testbot_commands.rs b/examples/testbot_commands.rs index bacab89..f6d184a 100644 --- a/examples/testbot_commands.rs +++ b/examples/testbot_commands.rs @@ -1,3 +1,5 @@ +#![allow(unused_crate_dependencies)] + // TODO Add description // TODO Clean up and unify test bots diff --git a/examples/testbot_instance.rs b/examples/testbot_instance.rs index c1c2895..f748429 100644 --- a/examples/testbot_instance.rs +++ b/examples/testbot_instance.rs @@ -1,5 +1,6 @@ //! Similar to the `testbot_manual` example, but using [`Instance`] to connect //! to the room (and to reconnect). +#![allow(unused_crate_dependencies)] use euphoxide::api::packet::ParsedPacket; use euphoxide::api::{Data, Nick, Send}; diff --git a/examples/testbot_instances.rs b/examples/testbot_instances.rs index d44cbe7..2ad134b 100644 --- a/examples/testbot_instances.rs +++ b/examples/testbot_instances.rs @@ -1,5 +1,6 @@ //! Similar to the `testbot_manual` example, but using [`Instance`] to connect //! to the room (and to reconnect). +#![allow(unused_crate_dependencies)] use euphoxide::api::packet::ParsedPacket; use euphoxide::api::{Data, Nick, Send}; diff --git a/examples/testbot_manual.rs b/examples/testbot_manual.rs index d6535a4..71a7280 100644 --- a/examples/testbot_manual.rs +++ b/examples/testbot_manual.rs @@ -1,5 +1,6 @@ //! A small bot that doesn't use the `bot` submodule. Meant to show how the main //! parts of the API fit together. +#![allow(unused_crate_dependencies)] use std::error::Error; use std::time::Duration; diff --git a/src/lib.rs b/src/lib.rs index 66fb34e..380b321 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1,14 +1,3 @@ -#![forbid(unsafe_code)] -// Rustc lint groups -#![warn(future_incompatible)] -#![warn(rust_2018_idioms)] -#![warn(unused)] -// Rustc lints -#![warn(noop_method_call)] -#![warn(single_use_lifetimes)] -// Clippy lints -#![warn(clippy::use_self)] - pub mod api; #[cfg(feature = "bot")] pub mod bot; From f973a819b6e3d1ff6c1d55b76747199e3cae5489 Mon Sep 17 00:00:00 2001 From: Joscha Date: Wed, 4 Dec 2024 17:14:55 +0100 Subject: [PATCH 04/15] Make botrulez submodules public This allows users of the library to use the commands' Args structs. --- CHANGELOG.md | 7 +++++++ src/bot/botrulez.rs | 8 ++++---- src/bot/botrulez/uptime.rs | 2 +- 3 files changed, 12 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 287c658..d741133 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -14,6 +14,13 @@ Procedure when bumping the version number: ## Unreleased +### Added + +- `bot::botrulez::full_help` +- `bot::botrulez::ping` +- `bot::botrulez::short_help` +- `bot::botrulez::uptime` + ### Changed - **(breaking)** Switched to `jiff` from `time` diff --git a/src/bot/botrulez.rs b/src/bot/botrulez.rs index 3161ad6..2120ce3 100644 --- a/src/bot/botrulez.rs +++ b/src/bot/botrulez.rs @@ -1,8 +1,8 @@ //! The main [botrulez](https://github.com/jedevc/botrulez) commands. -mod full_help; -mod ping; -mod short_help; -mod uptime; +pub mod full_help; +pub mod ping; +pub mod short_help; +pub mod uptime; pub use self::full_help::{FullHelp, HasDescriptions}; pub use self::ping::Ping; diff --git a/src/bot/botrulez/uptime.rs b/src/bot/botrulez/uptime.rs index 1c98ff6..7f79ba3 100644 --- a/src/bot/botrulez/uptime.rs +++ b/src/bot/botrulez/uptime.rs @@ -100,7 +100,7 @@ where pub struct Args { /// Show how long the bot has been connected without interruption. #[arg(long, short)] - connected: bool, + pub connected: bool, } #[async_trait] From 61f5559370a80a38f7fa5a629112045887c0a812 Mon Sep 17 00:00:00 2001 From: Joscha Date: Wed, 4 Dec 2024 18:24:18 +0100 Subject: [PATCH 05/15] Document rustls panic in changelog --- CHANGELOG.md | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index d741133..54b8300 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -24,6 +24,13 @@ Procedure when bumping the version number: ### Changed - **(breaking)** Switched to `jiff` from `time` +- **(breaking)** Bumped `tokio-tungstenite` dependency from `0.18` to `0.24`. If + this causes a panic while using euphoxide, consider following the steps + mentioned in the [tokio-tungstenite README]. If I'm reading the [rustls docs] + correctly, it is on the users of the libraries to set the required features. + +[tokio-tungstenite README]: https://github.com/snapview/tokio-tungstenite?tab=readme-ov-file#features +[rustls docs]: https://docs.rs/rustls/0.23.19/rustls/crypto/struct.CryptoProvider.html#using-the-per-process-default-cryptoprovider ## v0.5.1 - 2024-05-20 From 7360bf96f81a52f422fbe35a7d093571e9c79533 Mon Sep 17 00:00:00 2001 From: Joscha Date: Wed, 4 Dec 2024 18:52:29 +0100 Subject: [PATCH 06/15] Fix rustls panic in example bots --- Cargo.toml | 2 +- examples/testbot_commands.rs | 7 +++++-- examples/testbot_instance.rs | 6 +++++- examples/testbot_instances.rs | 6 +++++- examples/testbot_manual.rs | 6 +++++- 5 files changed, 21 insertions(+), 6 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 917f0b4..0ae6832 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -27,6 +27,7 @@ default-features = false features = ["std", "derive", "deprecated"] [dev-dependencies] # For example bot +rustls = "0.23.19" tokio = { version = "1.42.0", features = ["rt-multi-thread"] } [[example]] @@ -56,7 +57,6 @@ rust.redundant_lifetimes = "warn" rust.single_use_lifetimes = "warn" rust.unit_bindings = "warn" rust.unnameable_types = "warn" -rust.unused_crate_dependencies = "warn" rust.unused_import_braces = "warn" rust.unused_lifetimes = "warn" rust.unused_qualifications = "warn" diff --git a/examples/testbot_commands.rs b/examples/testbot_commands.rs index f6d184a..c3afada 100644 --- a/examples/testbot_commands.rs +++ b/examples/testbot_commands.rs @@ -1,5 +1,3 @@ -#![allow(unused_crate_dependencies)] - // TODO Add description // TODO Clean up and unify test bots @@ -94,6 +92,11 @@ impl HasStartTime for Bot { #[tokio::main] async fn main() { + // https://github.com/snapview/tokio-tungstenite/issues/353#issuecomment-2455247837 + rustls::crypto::aws_lc_rs::default_provider() + .install_default() + .unwrap(); + let (tx, mut rx) = mpsc::unbounded_channel(); let mut instances = Instances::new(ServerConfig::default()); diff --git a/examples/testbot_instance.rs b/examples/testbot_instance.rs index f748429..f60f3b9 100644 --- a/examples/testbot_instance.rs +++ b/examples/testbot_instance.rs @@ -1,6 +1,5 @@ //! Similar to the `testbot_manual` example, but using [`Instance`] to connect //! to the room (and to reconnect). -#![allow(unused_crate_dependencies)] use euphoxide::api::packet::ParsedPacket; use euphoxide::api::{Data, Nick, Send}; @@ -123,6 +122,11 @@ async fn on_packet(packet: ParsedPacket, snapshot: ConnSnapshot) -> Result<(), ( #[tokio::main] async fn main() { + // https://github.com/snapview/tokio-tungstenite/issues/353#issuecomment-2455247837 + rustls::crypto::aws_lc_rs::default_provider() + .install_default() + .unwrap(); + let (tx, mut rx) = mpsc::unbounded_channel(); let _instance = ServerConfig::default() diff --git a/examples/testbot_instances.rs b/examples/testbot_instances.rs index 2ad134b..0fb612f 100644 --- a/examples/testbot_instances.rs +++ b/examples/testbot_instances.rs @@ -1,6 +1,5 @@ //! Similar to the `testbot_manual` example, but using [`Instance`] to connect //! to the room (and to reconnect). -#![allow(unused_crate_dependencies)] use euphoxide::api::packet::ParsedPacket; use euphoxide::api::{Data, Nick, Send}; @@ -124,6 +123,11 @@ async fn on_packet(packet: ParsedPacket, snapshot: ConnSnapshot) -> Result<(), ( #[tokio::main] async fn main() { + // https://github.com/snapview/tokio-tungstenite/issues/353#issuecomment-2455247837 + rustls::crypto::aws_lc_rs::default_provider() + .install_default() + .unwrap(); + let (tx, mut rx) = mpsc::unbounded_channel(); let mut instances = Instances::new(ServerConfig::default()); diff --git a/examples/testbot_manual.rs b/examples/testbot_manual.rs index 71a7280..da21db0 100644 --- a/examples/testbot_manual.rs +++ b/examples/testbot_manual.rs @@ -1,6 +1,5 @@ //! A small bot that doesn't use the `bot` submodule. Meant to show how the main //! parts of the API fit together. -#![allow(unused_crate_dependencies)] use std::error::Error; use std::time::Duration; @@ -127,6 +126,11 @@ async fn on_packet(packet: ParsedPacket, conn_tx: &ConnTx, state: &State) -> Res #[tokio::main] async fn main() -> Result<(), Box> { + // https://github.com/snapview/tokio-tungstenite/issues/353#issuecomment-2455247837 + rustls::crypto::aws_lc_rs::default_provider() + .install_default() + .unwrap(); + let (mut conn, _) = Conn::connect(DOMAIN, ROOM, false, None, TIMEOUT).await?; while let Ok(packet) = conn.recv().await { From cdcf80ab9abdeb11a5498bebd44752bf9fe507d5 Mon Sep 17 00:00:00 2001 From: Joscha Date: Wed, 4 Dec 2024 18:56:03 +0100 Subject: [PATCH 07/15] Fix timestamps with too much precision being representable --- CHANGELOG.md | 7 +++++++ src/api/types.rs | 12 ++++++++---- src/conn.rs | 2 +- 3 files changed, 16 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 54b8300..6ef9b70 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -16,6 +16,8 @@ Procedure when bumping the version number: ### Added +- `api::Time::from_timestamp` +- `api::Time::as_timestamp` - `bot::botrulez::full_help` - `bot::botrulez::ping` - `bot::botrulez::short_help` @@ -24,6 +26,7 @@ Procedure when bumping the version number: ### Changed - **(breaking)** Switched to `jiff` from `time` +- **(breaking)** `api::Time` contents are now an `i64` - **(breaking)** Bumped `tokio-tungstenite` dependency from `0.18` to `0.24`. If this causes a panic while using euphoxide, consider following the steps mentioned in the [tokio-tungstenite README]. If I'm reading the [rustls docs] @@ -32,6 +35,10 @@ Procedure when bumping the version number: [tokio-tungstenite README]: https://github.com/snapview/tokio-tungstenite?tab=readme-ov-file#features [rustls docs]: https://docs.rs/rustls/0.23.19/rustls/crypto/struct.CryptoProvider.html#using-the-per-process-default-cryptoprovider +### Removed + +- `api::Time::new` + ## v0.5.1 - 2024-05-20 ### Added diff --git a/src/api/types.rs b/src/api/types.rs index 8f438e9..b1408a8 100644 --- a/src/api/types.rs +++ b/src/api/types.rs @@ -403,15 +403,19 @@ impl<'de> Deserialize<'de> for Snowflake { /// Time is specified as a signed 64-bit integer, giving the number of seconds /// since the Unix Epoch. #[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)] -pub struct Time(#[serde(with = "jiff::fmt::serde::timestamp::second::required")] pub Timestamp); +pub struct Time(pub i64); impl Time { - pub fn new(time: Timestamp) -> Self { - Self(time) + pub fn from_timestamp(time: Timestamp) -> Self { + Self(time.as_second()) + } + + pub fn as_timestamp(&self) -> Timestamp { + Timestamp::from_second(self.0).unwrap() } pub fn now() -> Self { - Self::new(Timestamp::now()) + Self::from_timestamp(Timestamp::now()) } } diff --git a/src/conn.rs b/src/conn.rs index 8d6820c..6d88827 100644 --- a/src/conn.rs +++ b/src/conn.rs @@ -531,7 +531,7 @@ impl Conn { self.ws.send(tungstenite::Message::Ping(ws_payload)).await?; // Send new euph ping - let euph_payload = Time::new(now); + let euph_payload = Time::from_timestamp(now); self.last_euph_ping_payload = Some(euph_payload); self.last_euph_ping_replied_to = false; let (tx, _) = oneshot::channel(); From 58b55ef4338a7bb3aeae091b8bb79867f01fa083 Mon Sep 17 00:00:00 2001 From: Joscha Date: Wed, 4 Dec 2024 18:56:52 +0100 Subject: [PATCH 08/15] Fix link to euph api in docs --- src/api.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/api.rs b/src/api.rs index d72b91c..e24ca1d 100644 --- a/src/api.rs +++ b/src/api.rs @@ -1,6 +1,6 @@ //! Models the [euphoria API][0]. //! -//! [0](https://github.com/CylonicRaider/heim/blob/master/doc/api.md) +//! [0]: https://euphoria.leet.nu/heim/api mod account_cmds; mod events; From fe6869493225abb1229631816ffdc2fdae5d32e3 Mon Sep 17 00:00:00 2001 From: Joscha Date: Wed, 4 Dec 2024 20:01:32 +0100 Subject: [PATCH 09/15] Fix time and duration formatting --- CHANGELOG.md | 3 +++ src/bot/botrulez.rs | 2 +- src/bot/botrulez/uptime.rs | 30 +++++++++++++++++++----------- 3 files changed, 23 insertions(+), 12 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 6ef9b70..6dfca90 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -22,6 +22,7 @@ Procedure when bumping the version number: - `bot::botrulez::ping` - `bot::botrulez::short_help` - `bot::botrulez::uptime` +- `bot::botrulez::format_relative_time` ### Changed @@ -31,6 +32,8 @@ Procedure when bumping the version number: this causes a panic while using euphoxide, consider following the steps mentioned in the [tokio-tungstenite README]. If I'm reading the [rustls docs] correctly, it is on the users of the libraries to set the required features. +- `bot::botrulez::format_duration` now no longer mentions "since" or "ago", but + instead has a sign (`-`) if the duration is negative. [tokio-tungstenite README]: https://github.com/snapview/tokio-tungstenite?tab=readme-ov-file#features [rustls docs]: https://docs.rs/rustls/0.23.19/rustls/crypto/struct.CryptoProvider.html#using-the-per-process-default-cryptoprovider diff --git a/src/bot/botrulez.rs b/src/bot/botrulez.rs index 2120ce3..6dd5adb 100644 --- a/src/bot/botrulez.rs +++ b/src/bot/botrulez.rs @@ -7,4 +7,4 @@ pub mod uptime; pub use self::full_help::{FullHelp, HasDescriptions}; pub use self::ping::Ping; pub use self::short_help::ShortHelp; -pub use self::uptime::{format_duration, format_time, HasStartTime, Uptime}; +pub use self::uptime::{format_duration, format_relative_time, format_time, HasStartTime, Uptime}; diff --git a/src/bot/botrulez/uptime.rs b/src/bot/botrulez/uptime.rs index 7f79ba3..d8b1d0d 100644 --- a/src/bot/botrulez/uptime.rs +++ b/src/bot/botrulez/uptime.rs @@ -1,21 +1,29 @@ use async_trait::async_trait; use clap::Parser; -use jiff::{Span, Timestamp}; +use jiff::{Span, Timestamp, Unit}; use crate::api::Message; use crate::bot::command::{ClapCommand, Command, Context}; use crate::conn; pub fn format_time(t: Timestamp) -> String { - t.strftime("%Y-&m-%d %H:%M:%S UTC").to_string() + t.strftime("%Y-%m-%d %H:%M:%S UTC").to_string() +} + +pub fn format_relative_time(d: Span) -> String { + if d.is_positive() { + format!("in {}", format_duration(d.abs())) + } else { + format!("{} ago", format_duration(d.abs())) + } } pub fn format_duration(d: Span) -> String { - let d_abs = d.abs(); - let days = d_abs.get_days(); - let hours = d_abs.get_hours() % 24; - let mins = d_abs.get_minutes() % 60; - let secs = d_abs.get_seconds() % 60; + let total = d.abs().total(Unit::Second).unwrap() as i64; + let secs = total % 60; + let mins = (total / 60) % 60; + let hours = (total / 60 / 60) % 24; + let days = total / 60 / 60 / 24; let mut segments = vec![]; if days > 0 { @@ -36,9 +44,9 @@ pub fn format_duration(d: Span) -> String { let segments = segments.join(" "); if d.is_positive() { - format!("in {segments}") + segments } else { - format!("{segments} ago") + format!("-{segments}") } } @@ -56,7 +64,7 @@ impl Uptime { let mut reply = format!( "/me has been up since {} ({})", format_time(start), - format_duration(start - now), + format_relative_time(start - now), ); if connected { @@ -64,7 +72,7 @@ impl Uptime { reply.push_str(&format!( ", connected since {} ({})", format_time(since), - format_duration(since - now), + format_relative_time(since - now), )); } From bc3e3b1e13f4ac78b4df3096d9ff4c0cbdbbc4f6 Mon Sep 17 00:00:00 2001 From: Joscha Date: Thu, 20 Feb 2025 20:16:11 +0100 Subject: [PATCH 10/15] Update tokio-tungstenite --- Cargo.toml | 2 +- src/conn.rs | 10 ++++++---- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 0ae6832..ed9c7f4 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -17,7 +17,7 @@ serde = { version = "1.0.215", features = ["derive"] } serde_json = "1.0.133" tokio = { version = "1.42.0", features = ["time", "sync", "macros", "rt"] } tokio-stream = "0.1.16" -tokio-tungstenite = { version = "0.24.0", features = ["rustls-tls-native-roots"] } +tokio-tungstenite = { version = "0.26.2", features = ["rustls-tls-native-roots"] } unicode-normalization = "0.1.24" [dependencies.clap] diff --git a/src/conn.rs b/src/conn.rs index 6d88827..7255d60 100644 --- a/src/conn.rs +++ b/src/conn.rs @@ -427,7 +427,7 @@ impl Conn { } tungstenite::Message::Ping(_) => {} tungstenite::Message::Pong(payload) => { - if self.last_ws_ping_payload == Some(payload) { + if self.last_ws_ping_payload == Some(payload.to_vec()) { self.last_ws_ping_replied_to = true; } } @@ -528,7 +528,9 @@ impl Conn { let ws_payload = now.as_millisecond().to_be_bytes().to_vec(); self.last_ws_ping_payload = Some(ws_payload.clone()); self.last_ws_ping_replied_to = false; - self.ws.send(tungstenite::Message::Ping(ws_payload)).await?; + self.ws + .send(tungstenite::Message::Ping(ws_payload.into())) + .await?; // Send new euph ping let euph_payload = Time::from_timestamp(now); @@ -561,7 +563,7 @@ impl Conn { .into_packet()?; debug!(target: "euphoxide::conn::full", "Sending {packet:?}"); - let msg = tungstenite::Message::Text(serde_json::to_string(&packet)?); + let msg = tungstenite::Message::Text(serde_json::to_string(&packet)?.into()); self.ws.send(msg).await?; let _ = reply_tx.send(self.replies.wait_for(id)); @@ -579,7 +581,7 @@ impl Conn { .into_packet()?; debug!(target: "euphoxide::conn::full", "Sending {packet:?}"); - let msg = tungstenite::Message::Text(serde_json::to_string(&packet)?); + let msg = tungstenite::Message::Text(serde_json::to_string(&packet)?.into()); self.ws.send(msg).await?; Ok(()) From 1d444684f7f292183c1ab5c89fef3872dadf96fd Mon Sep 17 00:00:00 2001 From: Joscha Date: Thu, 20 Feb 2025 20:16:50 +0100 Subject: [PATCH 11/15] Update dependencies --- Cargo.toml | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index ed9c7f4..8d4f092 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -7,28 +7,28 @@ edition = "2021" bot = ["dep:async-trait", "dep:clap", "dep:cookie"] [dependencies] -async-trait = { version = "0.1.83", optional = true } -caseless = "0.2.1" +async-trait = { version = "0.1.86", optional = true } +caseless = "0.2.2" cookie = { version = "0.18.1", optional = true } futures-util = { version = "0.3.31", default-features = false, features = ["sink"] } -jiff = { version = "0.1.15", features = ["serde"] } -log = "0.4.22" -serde = { version = "1.0.215", features = ["derive"] } -serde_json = "1.0.133" -tokio = { version = "1.42.0", features = ["time", "sync", "macros", "rt"] } -tokio-stream = "0.1.16" +jiff = { version = "0.2.1", features = ["serde"] } +log = "0.4.25" +serde = { version = "1.0.218", features = ["derive"] } +serde_json = "1.0.139" +tokio = { version = "1.43.0", features = ["time", "sync", "macros", "rt"] } +tokio-stream = "0.1.17" tokio-tungstenite = { version = "0.26.2", features = ["rustls-tls-native-roots"] } unicode-normalization = "0.1.24" [dependencies.clap] -version = "4.5.22" +version = "4.5.30" optional = true default-features = false features = ["std", "derive", "deprecated"] [dev-dependencies] # For example bot -rustls = "0.23.19" -tokio = { version = "1.42.0", features = ["rt-multi-thread"] } +rustls = "0.23.23" +tokio = { version = "1.43.0", features = ["rt-multi-thread"] } [[example]] name = "testbot_instance" From 4f7cc49b636301ce9beea9324a0a1390f8391009 Mon Sep 17 00:00:00 2001 From: Joscha Date: Fri, 21 Feb 2025 00:40:15 +0100 Subject: [PATCH 12/15] Bump version to 0.6.0 --- CHANGELOG.md | 2 ++ Cargo.toml | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 6dfca90..aef37c6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -14,6 +14,8 @@ Procedure when bumping the version number: ## Unreleased +## v0.6.0 - 2025-02-21 + ### Added - `api::Time::from_timestamp` diff --git a/Cargo.toml b/Cargo.toml index 8d4f092..1e6a0b4 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "euphoxide" -version = "0.5.1" +version = "0.6.0" edition = "2021" [features] From 6eea194d52fb63d7fb260d06e61d0625addf8c67 Mon Sep 17 00:00:00 2001 From: Joscha Date: Sun, 23 Feb 2025 21:37:44 +0100 Subject: [PATCH 13/15] Update emoji --- CHANGELOG.md | 4 ++++ src/emoji.json | 5 +++-- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index aef37c6..04d83a2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -14,6 +14,10 @@ Procedure when bumping the version number: ## Unreleased +### Changed + +- Updated set of emoji names + ## v0.6.0 - 2025-02-21 ### Added diff --git a/src/emoji.json b/src/emoji.json index e9f8068..b26a1f7 100644 --- a/src/emoji.json +++ b/src/emoji.json @@ -878,7 +878,7 @@ "fist_raised": "270a", "fist_right": "1f91c", "five": "35-fe0f-20e3", - "fjafjkldskf7jkfdj": "1f577", + "fjafjkldskf7jkfdj": "1f577-fe0f", "flags": "1f38f", "flamingo": "1f9a9", "flashlight": "1f526", @@ -958,6 +958,7 @@ "georgia": "1f1ec-1f1ea", "ghana": "1f1ec-1f1ed", "ghost": "1f47b", + "ghoti": "1f41f", "gibraltar": "1f1ec-1f1ee", "gift": "1f381", "gift_heart": "1f49d", @@ -2985,7 +2986,7 @@ "speaking_head": "1f5e3-fe0f", "speech_balloon": "1f4ac", "speedboat": "1f6a4", - "spider": "1f577", + "spider": "1f577-fe0f", "spider_web": "1f578-fe0f", "spiral_calendar": "1f5d3-fe0f", "spiral_notepad": "1f5d2-fe0f", From 095d2cea86a574732e82385e217381b35cf65e4d Mon Sep 17 00:00:00 2001 From: Joscha Date: Sun, 23 Feb 2025 22:34:22 +0100 Subject: [PATCH 14/15] Fix nick hue hashing algorithm in some edge cases When the nick consisted entirely of non-alphanumeric characters and included at least one colon-delimited emoji, the hue hashing reimplementation would produce an incorrect result because colon-delimited emoji were removed at the wrong point in the hashing process. --- CHANGELOG.md | 4 ++++ src/nick.rs | 26 +++++++++++++++++++------- 2 files changed, 23 insertions(+), 7 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 04d83a2..bec1e03 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -18,6 +18,10 @@ Procedure when bumping the version number: - Updated set of emoji names +### Fixed + +- Nick hue hashing algorithm in some edge cases + ## v0.6.0 - 2025-02-21 ### Added diff --git a/src/nick.rs b/src/nick.rs index 03ada70..fc652bf 100644 --- a/src/nick.rs +++ b/src/nick.rs @@ -5,9 +5,10 @@ use unicode_normalization::UnicodeNormalization; use crate::emoji::Emoji; -/// Does not remove emoji. -fn hue_normalize(text: &str) -> String { - text.chars() +fn hue_normalize(emoji: &Emoji, text: &str) -> String { + emoji + .remove(text) + .chars() .filter(|&c| c.is_ascii_alphanumeric() || c == '_' || c == '-') .map(|c| c.to_ascii_lowercase()) .collect() @@ -15,7 +16,7 @@ fn hue_normalize(text: &str) -> String { /// A re-implementation of [euphoria's nick hue hashing algorithm][0]. /// -/// [0]: https://github.com/CylonicRaider/heim/blob/master/client/lib/hueHash.js +/// [0]: https://github.com/CylonicRaider/heim/blob/097a1fde89ada53de2b70e51e635257f27956e4e/client/lib/heim/hueHash.js fn hue_hash(text: &str, offset: i64) -> u8 { let mut val = 0_i32; for bibyte in text.encode_utf16() { @@ -35,7 +36,13 @@ const GREENIE_OFFSET: i64 = 148 - 192; // 148 - hue_hash("greenie", 0) /// This should be slightly faster than [`hue`] but produces incorrect results /// if any colon-delimited emoji are present. pub fn hue_without_removing_emoji(nick: &str) -> u8 { - let normalized = hue_normalize(nick); + // An emoji-less version of hue_normalize + let normalized = nick + .chars() + .filter(|&c| c.is_ascii_alphanumeric() || c == '_' || c == '-') + .map(|c| c.to_ascii_lowercase()) + .collect::(); + if normalized.is_empty() { hue_hash(nick, GREENIE_OFFSET) } else { @@ -48,9 +55,14 @@ pub fn hue_without_removing_emoji(nick: &str) -> u8 { /// This is a reimplementation of [euphoria's nick hue hashing algorithm][0]. It /// should always return the same value as the official client's implementation. /// -/// [0]: https://github.com/CylonicRaider/heim/blob/978c921063e6b06012fc8d16d9fbf1b3a0be1191/client/lib/hueHash.js +/// [0]: https://github.com/CylonicRaider/heim/blob/097a1fde89ada53de2b70e51e635257f27956e4e/client/lib/heim/hueHash.js pub fn hue(emoji: &Emoji, nick: &str) -> u8 { - hue_without_removing_emoji(&emoji.remove(nick)) + let normalized = hue_normalize(emoji, nick); + if normalized.is_empty() { + hue_hash(nick, GREENIE_OFFSET) + } else { + hue_hash(&normalized, GREENIE_OFFSET) + } } /// Normalize a nick to a form that can be compared against other nicks. From 7a292c429ad44aa6aa52fc381e3168841d6303b0 Mon Sep 17 00:00:00 2001 From: Joscha Date: Sun, 23 Feb 2025 23:33:28 +0100 Subject: [PATCH 15/15] Bump version to 0.6.1 --- CHANGELOG.md | 2 ++ Cargo.toml | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index bec1e03..524e877 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -14,6 +14,8 @@ Procedure when bumping the version number: ## Unreleased +## v0.6.1 - 2025-02-23 + ### Changed - Updated set of emoji names diff --git a/Cargo.toml b/Cargo.toml index 1e6a0b4..cf65579 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "euphoxide" -version = "0.6.0" +version = "0.6.1" edition = "2021" [features]