From 781e25470b158bbd829d094474221a2fae5e867d Mon Sep 17 00:00:00 2001 From: Jonas Rabenstein Date: Mon, 16 Feb 2026 02:51:10 +0100 Subject: [PATCH 01/15] initial git dump --- api/Cargo.toml | 29 +++ api/src/authentication/login/email.rs | 16 ++ api/src/authentication/login/mod.rs | 22 +++ api/src/authentication/login/phone.rs | 16 ++ api/src/authentication/mod.rs | 14 ++ api/src/authentication/token.rs | 74 ++++++++ api/src/authorization.rs | 2 + api/src/error.rs | 67 +++++++ api/src/id.rs | 50 +++++ api/src/lib.rs | 20 ++ api/src/reqwest/client.rs | 133 +++++++++++++ api/src/reqwest/mod.rs | 250 +++++++++++++++++++++++++ api/src/schema/mod.rs | 1 + api/src/schema/sponds.rs | 57 ++++++ api/src/schema/sponds_upcoming.json | 1 + api/src/traits/authentication/login.rs | 1 + api/src/traits/authentication/mod.rs | 2 + api/src/traits/authorization.rs | 11 ++ api/src/traits/client.rs | 80 ++++++++ api/src/traits/endpoint.rs | 53 ++++++ api/src/traits/id.rs | 22 +++ api/src/traits/mod.rs | 17 ++ api/src/traits/request.rs | 5 + api/src/traits/schema.rs | 17 ++ api/src/traits/test.rs | 53 ++++++ api/src/utils/mod.rs | 5 + api/src/utils/timestamp.rs | 2 + api/src/utils/x128.rs | 78 ++++++++ flake.lock | 25 +++ flake.nix | 59 ++++++ turnerbund/:w | 231 +++++++++++++++++++++++ turnerbund/Cargo.toml | 25 +++ turnerbund/src/api/api.rs | 201 ++++++++++++++++++++ turnerbund/src/api/auth.rs | 185 ++++++++++++++++++ turnerbund/src/api/endpoint/mod.rs | 24 +++ turnerbund/src/api/error.rs | 29 +++ turnerbund/src/api/mod.rs | 32 ++++ turnerbund/src/api/request.rs | 13 ++ turnerbund/src/api/token.rs | 38 ++++ turnerbund/src/client/mod.rs | 10 + turnerbund/src/id.rs | 74 ++++++++ turnerbund/src/main.rs | 51 +++++ turnerbund/src/select.rs | 166 ++++++++++++++++ turnerbund/src/select/candidate.rs | 48 +++++ turnerbund/src/select/key.rs | 31 +++ turnerbund/src/user.rs | 2 + turnerbund/src/utils.rs | 19 ++ 47 files changed, 2361 insertions(+) create mode 100644 api/Cargo.toml create mode 100644 api/src/authentication/login/email.rs create mode 100644 api/src/authentication/login/mod.rs create mode 100644 api/src/authentication/login/phone.rs create mode 100644 api/src/authentication/mod.rs create mode 100644 api/src/authentication/token.rs create mode 100644 api/src/authorization.rs create mode 100644 api/src/error.rs create mode 100644 api/src/id.rs create mode 100644 api/src/lib.rs create mode 100644 api/src/reqwest/client.rs create mode 100644 api/src/reqwest/mod.rs create mode 100644 api/src/schema/mod.rs create mode 100644 api/src/schema/sponds.rs create mode 100644 api/src/schema/sponds_upcoming.json create mode 100644 api/src/traits/authentication/login.rs create mode 100644 api/src/traits/authentication/mod.rs create mode 100644 api/src/traits/authorization.rs create mode 100644 api/src/traits/client.rs create mode 100644 api/src/traits/endpoint.rs create mode 100644 api/src/traits/id.rs create mode 100644 api/src/traits/mod.rs create mode 100644 api/src/traits/request.rs create mode 100644 api/src/traits/schema.rs create mode 100644 api/src/traits/test.rs create mode 100644 api/src/utils/mod.rs create mode 100644 api/src/utils/timestamp.rs create mode 100644 api/src/utils/x128.rs create mode 100644 flake.lock create mode 100644 flake.nix create mode 100644 turnerbund/:w create mode 100644 turnerbund/Cargo.toml create mode 100644 turnerbund/src/api/api.rs create mode 100644 turnerbund/src/api/auth.rs create mode 100644 turnerbund/src/api/endpoint/mod.rs create mode 100644 turnerbund/src/api/error.rs create mode 100644 turnerbund/src/api/mod.rs create mode 100644 turnerbund/src/api/request.rs create mode 100644 turnerbund/src/api/token.rs create mode 100644 turnerbund/src/client/mod.rs create mode 100644 turnerbund/src/id.rs create mode 100644 turnerbund/src/main.rs create mode 100644 turnerbund/src/select.rs create mode 100644 turnerbund/src/select/candidate.rs create mode 100644 turnerbund/src/select/key.rs create mode 100644 turnerbund/src/user.rs create mode 100644 turnerbund/src/utils.rs diff --git a/api/Cargo.toml b/api/Cargo.toml new file mode 100644 index 0000000..c9643b8 --- /dev/null +++ b/api/Cargo.toml @@ -0,0 +1,29 @@ +[package] +name = "spond" +version = "0.1.0" +edition = "2024" + +[features] +reqwest = [ "dep:reqwest", "reqwest/json" ] +log = [ "tracing/log" ] +tracing = [ ] +cookies = [ "reqwest?/cookies" ] + + +[dependencies] +async-trait = "0.1.89" +bon = "3.9.0" +bytes = "1.11.1" +chrono = { version = "0.4.43", features = ["serde"] } +#macro = { path = "../macro" } +reqwest = { version = "0.13.2", optional = true } +serde = { version = "1.0.228", features = ["derive"] } +serde_json = "1.0.149" +#spond-auth-login = { version = "0.1.0", path = "../login" } +thiserror = "2.0.18" +tokio = { version = "1.49.0" } +tracing = { version = "0.1.44", features = [] } +url = "2.5.8" + +[dev-dependencies] +tokio = { version = "1.49.0", features = ["macros"] } diff --git a/api/src/authentication/login/email.rs b/api/src/authentication/login/email.rs new file mode 100644 index 0000000..678b60b --- /dev/null +++ b/api/src/authentication/login/email.rs @@ -0,0 +1,16 @@ +#[derive(Debug, serde::Serialize)] +pub struct Email { + email: String, + password: String, +} + +impl Email { + pub fn new(email: &str, password: &str) -> Self { + Self { + email: email.to_string(), + password: password.to_string(), + } + } +} + +impl super::Credentials for Email {} diff --git a/api/src/authentication/login/mod.rs b/api/src/authentication/login/mod.rs new file mode 100644 index 0000000..8ac83b5 --- /dev/null +++ b/api/src/authentication/login/mod.rs @@ -0,0 +1,22 @@ +mod email; +mod phone; + +pub use email::Email; +pub use phone::Phone; + +use crate::{ + Method, + authentication::Tokens, + traits::{authentication::login::Credentials, endpoint}, +}; + +pub struct Login; + +impl endpoint::Public for Login { + const METHOD: Method = Method::POST; + type Schema = Tokens; + + fn path(&self, _: &C) -> &str { + "core/v1/auth2/login" + } +} diff --git a/api/src/authentication/login/phone.rs b/api/src/authentication/login/phone.rs new file mode 100644 index 0000000..ad68c23 --- /dev/null +++ b/api/src/authentication/login/phone.rs @@ -0,0 +1,16 @@ +#[derive(Debug, serde::Serialize)] +pub struct Phone { + phone: String, + password: String, +} + +impl Phone { + pub fn new(phone: &str, password: &str) -> Self { + Self { + phone: phone.to_string(), + password: password.to_string(), + } + } +} + +impl super::Credentials for Phone {} diff --git a/api/src/authentication/mod.rs b/api/src/authentication/mod.rs new file mode 100644 index 0000000..bba562c --- /dev/null +++ b/api/src/authentication/mod.rs @@ -0,0 +1,14 @@ +pub mod login; +pub mod token; + +pub use login::Login; +pub use token::Token; + +use serde::Deserialize; + +#[derive(Debug, Deserialize)] +#[serde(rename_all = "camelCase")] +pub struct Tokens { + pub access_token: token::Access, + pub refresh_token: token::Refresh, +} diff --git a/api/src/authentication/token.rs b/api/src/authentication/token.rs new file mode 100644 index 0000000..a7bdce8 --- /dev/null +++ b/api/src/authentication/token.rs @@ -0,0 +1,74 @@ +use crate::traits::Request; +use chrono::{DateTime, Utc}; +use serde::{Deserialize, Serialize}; + +use std::ops::Deref; + +#[derive(Debug, Clone, Deserialize)] +pub struct Access(Expire); + +impl Deref for Access { + type Target = Expire; + + fn deref(&self) -> &Expire { + &self.0 + } +} + +#[derive(Debug, Clone, Deserialize, Serialize)] +pub struct Refresh(Expire); + +impl Deref for Refresh { + type Target = Expire; + + fn deref(&self) -> &Expire { + &self.0 + } +} + +#[derive(Debug, Clone, Deserialize, Serialize)] +pub struct Token { + token: String, +} + +impl AsRef for Token { + fn as_ref(&self) -> &str { + &self.token + } +} + +#[derive(Debug, Clone, Deserialize, Serialize)] +pub struct Expire { + #[serde(flatten)] + token: Token, + #[serde(skip_serializing)] + expiration: DateTime, +} + +impl Expire { + pub fn expired(&self) -> bool { + Utc::now() <= self.expiration + } +} + +impl Deref for Expire { + type Target = Token; + + fn deref(&self) -> &Token { + &self.token + } +} + +trait Factory: Serialize {} +impl Factory for Refresh {} +impl Factory for Token {} + +impl crate::traits::endpoint::Public for R +{ + const METHOD: crate::Method = crate::Method::POST; + type Schema = super::Tokens; + + fn path(&self, _: &R) -> &str { + "auth2/refresh" + } +} diff --git a/api/src/authorization.rs b/api/src/authorization.rs new file mode 100644 index 0000000..19c38d5 --- /dev/null +++ b/api/src/authorization.rs @@ -0,0 +1,2 @@ +pub struct True; +pub struct False; diff --git a/api/src/error.rs b/api/src/error.rs new file mode 100644 index 0000000..92ae258 --- /dev/null +++ b/api/src/error.rs @@ -0,0 +1,67 @@ +use thiserror::Error; + +pub mod api { + use thiserror::Error; + + pub type Refresh = Public; + + #[derive(Debug, Error)] + pub enum Private { + #[error("endpoint url")] + Url(url::ParseError), + + #[error("json decode")] + Decode(Decode), + + #[error("unauthorized")] + Unauthorized, + + #[error("token refresh")] // TODO: serde_json::Error -> Schema::...? + Refresh(Refresh), + + #[error("send error")] + Send(Transfer), + + #[error("receive error")] + Receive(Transfer), + } + + #[derive(Debug, Error)] + pub enum Public { + #[error("endpoint url")] + Url(url::ParseError), + + #[error("json decode")] + Decode(Decode), + + #[error("send error")] + Send(Transfer), + + #[error("receive error")] + Receive(Transfer), + } +} + +#[derive(Debug, Error)] +pub enum Id { + #[error("invalid length")] + Length(usize), + + #[error("invalid symbol")] + Parser(#[from] std::num::ParseIntError), +} + +#[derive(Debug, Error)] +pub enum Authorization { + #[error("unauthorized")] + Unauthorized, +} + +//#[derive(Debug, Error)] +//pub enum Authentication { +// #[error("unauthorized")] +// Public(A), +// +// #[error("authorized")] +// Private(B), +//} diff --git a/api/src/id.rs b/api/src/id.rs new file mode 100644 index 0000000..b4c4003 --- /dev/null +++ b/api/src/id.rs @@ -0,0 +1,50 @@ +use serde::{Serialize, Deserialize}; +use std::{ + fmt, + str::FromStr, + ops::Deref, +}; + +use crate::{ + utils::X128, + traits::id::Marker, +}; + +#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Serialize, Deserialize)] +pub struct Id { + #[serde(flatten)] + id: X128, + #[serde(skip)] + _marker: std::marker::PhantomData, +} + +impl Id { + pub fn new(value: impl Into) -> Self { + Self { + id: value.into(), + _marker: std::marker::PhantomData, + } + } +} + +impl Deref for Id { + type Target = X128; + + fn deref(&self) -> &X128 { + &self.id + } +} + +impl fmt::Display for Id { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + write!(f, "{}", self.id) + } +} + +impl FromStr for Id { + type Err = ::Err; + + fn from_str(s: &str) -> Result { + X128::from_str(s).map(Self::new) + } +} diff --git a/api/src/lib.rs b/api/src/lib.rs new file mode 100644 index 0000000..0fdb56e --- /dev/null +++ b/api/src/lib.rs @@ -0,0 +1,20 @@ +pub mod authentication; +pub mod authorization; +pub mod error; +pub mod id; +pub mod schema; +pub mod traits; + +mod utils; + +#[derive(Debug)] +pub enum Method { + GET, + POST, +} + +pub use id::Id; + + +#[cfg(feature = "reqwest")] +pub mod reqwest; diff --git a/api/src/reqwest/client.rs b/api/src/reqwest/client.rs new file mode 100644 index 0000000..d2e59e7 --- /dev/null +++ b/api/src/reqwest/client.rs @@ -0,0 +1,133 @@ +use async_trait::async_trait; +use crate::{ + authentication, + error, +}; +use crate::traits::{ + client, + endpoint, + Request, + Schema, +}; + +pub struct Public { + client: reqwest::Client, + base: url::Url, +} + +pub struct Private { + public: Public, + tokens: tokio::sync::RwLock, +} + +impl Private { + async fn current_token(&self) -> authentication::Token { + let tokens = self.tokens.read().await; + let token: &authentication::Token = (&*tokens).into(); + token.clone() + } + + async fn refresh_tokens(&self) -> Result> { + let mut tokens = self.tokens.write().await; + *tokens = (*tokens).refresh(self).await?; + let token: &authentication::Token = (&*tokens).into(); + Ok(token.clone()) + } +} + +pub type Client = Private; + + +type AuthorizedError, R: Request> = error::api::Private; +type UnauthorizedError, R: Request> = error::api::Public; + +async fn authorized(client: &reqwest::Client, method: reqwest::Method, base: &url::Url, path: &str, request: &R, token: &authentication::Token) -> Result> +where + R: Request + Sync, + S: Schema, +{ + let url = base.join(path).map_err(AuthorizedError::::Url)?; + + let response = client.request(method, url) + .json(request) + .bearer_auth(token.as_ref()) + .send() + .await + .map_err(AuthorizedError::::Send)?; + + let body = match response.status() { + _ => response.text_with_charset("utf-8") + .await + .map_err(AuthorizedError::::Receive)?, + }; + + S::deserialize(request, &body).map_err(AuthorizedError::::Decode) +} + +async fn unauthorized(client: &reqwest::Client, method: reqwest::Method, base: &url::Url, path: &str, request: &R) -> Result> +where + R: Request + Sync, + S: Schema, +{ + let url = base.join(path).map_err(UnauthorizedError::::Url)?; + + let response = client.request(method, url) + .json(request) + .send() + .await + .map_err(UnauthorizedError::::Send)?; + + let body = match response.status() { + _ => response.text_with_charset("utf-8") + .await + .map_err(UnauthorizedError::::Receive)?, + }; + + S::deserialize(request, &body).map_err(UnauthorizedError::::Decode) +} + +#[async_trait] +impl client::Public for Public { + type Error = reqwest::Error; + + async fn execute(&self, endpoint: &E, request: &R) -> Result>::Error>> + where + E: endpoint::Public + Sync, + R: Request + Sync, + { + unauthorized::(&self.client, E::METHOD.into(), &self.base, endpoint.path(request), &request).await + } +} + +#[async_trait] +impl client::Public for Private { + type Error = reqwest::Error; + + async fn execute(&self, endpoint: &E, request: &R) -> Result>::Error>> + where + E: endpoint::Public + Sync, + R: Request + Sync, + { + self.public.execute::(endpoint, request).await + } +} + +#[async_trait] +impl client::Private for Private { + type Error = reqwest::Error; + + async fn execute(&self, endpoint: &E, request: &R) -> Result>::Error>> + where + E: endpoint::Private + Sync, + R: Request + Sync, + { + let token = self.current_token().await; + match authorized::(&self.public.client, E::METHOD.into(), &self.public.base, endpoint.path(request), &request, &token).await { + Err(AuthorizedError::::Unauthorized) if token.expired() => { + let token = self.refresh_tokens().await.map_err(AuthorizedError::::Refresh)?; + authorized::(&self.public.client, E::METHOD.into(), &self.public.base, endpoint.path(request), &request, &token).await + }, + result => result, + } + } +} diff --git a/api/src/reqwest/mod.rs b/api/src/reqwest/mod.rs new file mode 100644 index 0000000..8b3f738 --- /dev/null +++ b/api/src/reqwest/mod.rs @@ -0,0 +1,250 @@ +use crate::Method; +pub use reqwest; + +impl From for reqwest::Method { + fn from(method: Method) -> Self { + match method { + Method::GET => reqwest::Method::GET, + Method::POST => reqwest::Method::POST, + } + } +} +use crate::traits::{Request, Schema, client, endpoint}; +use crate::{authentication, error}; +use async_trait::async_trait; + +#[derive(Debug, Clone)] +pub struct Public { + client: reqwest::Client, + base: url::Url, +} + +impl Public { + pub fn new() -> Result { + let base = url::Url::parse("https://api.spond.com").unwrap(); + Self::new_with_base(base) + } + + pub fn new_with_base(base: url::Url) -> Result { + let client = reqwest::Client::builder() + .https_only(true) + .redirect(reqwest::redirect::Policy::limited(1)); + #[cfg(feature = "cookies")] + let client = client.cookie_store(true); + #[cfg(feature = "tracing")] + let client = client.connection_verbose(true); + + let client = client + //.user_agent("...") + //.read_timeout(std::time::Duration) + //.connect_timeout(std::time::Duration) + .build()?; + Ok(Self { client, base }) + } +} + +#[async_trait] +impl client::Authenticator for Public { + type Private = Private; + + fn with_tokens(&self, tokens: authentication::Tokens) -> Self::Private { + Private { + public: self.clone(), + tokens: tokio::sync::RwLock::new(tokens), + } + } +} + +#[derive(Debug)] +pub struct Private { + public: Public, + tokens: tokio::sync::RwLock, +} + +impl Private { + async fn current_token(&self) -> authentication::token::Access { + let tokens = self.tokens.read().await; + tokens.access_token.clone() + } + + async fn refresh_tokens( + &self, + ) -> Result> { + use client::Public; + let mut tokens = self.tokens.write().await; + *tokens = self + .public + .execute(&tokens.refresh_token, &tokens.refresh_token) + .await?; + Ok((*tokens).access_token.clone()) + } +} + +pub type Client = Private; + +type AuthorizedError = error::api::Private>::Error>; +type UnauthorizedError = error::api::Public>::Error>; + +#[tracing::instrument] +async fn authorized( + client: &reqwest::Client, + method: reqwest::Method, + base: &url::Url, + path: &str, + request: &R, + token: &authentication::token::Access, +) -> Result> +where + R: Request + Sync, + S: Schema, +{ + let url = base.join(path).map_err(AuthorizedError::::Url)?; + + let builder = client + .request(method, url) + .json(request) + .bearer_auth(token.as_ref()); + tracing::debug!("request: {builder:?}"); + + let response = builder + .send() + .await + .map_err(AuthorizedError::::Send)?; + tracing::debug!("response: {response:?}"); + + let body = match response.status() { + _ => response + .bytes() + .await + .map_err(AuthorizedError::::Receive)?, + }; + tracing::debug!("body: {body:?}"); + + let result = S::deserialize(request, &body).map_err(AuthorizedError::::Decode)?; + tracing::debug!("result: {result:?}"); + + Ok(result) +} + +#[tracing::instrument] +async fn unauthorized( + client: &reqwest::Client, + method: reqwest::Method, + base: &url::Url, + path: &str, + request: &R, +) -> Result> +where + R: Request + Sync, + S: Schema, +{ + let url = base.join(path).map_err(UnauthorizedError::::Url)?; + + let builder = client + .request(method, url) + .json(request); + tracing::debug!("request: {builder:?}"); + let response = builder + .send() + .await + .map_err(UnauthorizedError::::Send)?; + tracing::debug!("response: {response:?}"); + + let body = match response.status() { + _ => response + .bytes() + .await + .map_err(UnauthorizedError::::Receive)?, + }; + tracing::debug!("body: {body:?}"); + + let result = S::deserialize(request, &body).map_err(UnauthorizedError::::Decode)?; + tracing::debug!("result: {result:?}"); + + Ok(result) +} + +#[async_trait] +impl client::Public for Public { + type Error = reqwest::Error; + + async fn execute( + &self, + endpoint: &E, + request: &R, + ) -> Result>::Error>> + where + E: endpoint::Public + Sync, + R: Request + Sync, + { + unauthorized::( + &self.client, + E::METHOD.into(), + &self.base, + endpoint.path(request), + &request, + ) + .await + } +} + +#[async_trait] +impl client::Public for Private { + type Error = reqwest::Error; + + async fn execute( + &self, + endpoint: &E, + request: &R, + ) -> Result>::Error>> + where + E: endpoint::Public + Sync, + R: Request + Sync, + { + self.public.execute::(endpoint, request).await + } +} + +#[async_trait] +impl client::Private for Private { + type Error = reqwest::Error; + + async fn execute( + &self, + endpoint: &E, + request: &R, + ) -> Result>::Error>> + where + E: endpoint::Private + Sync, + R: Request + Sync, + { + let token = self.current_token().await; + match authorized::( + &self.public.client, + E::METHOD.into(), + &self.public.base, + endpoint.path(request), + &request, + &token, + ) + .await + { + Err(AuthorizedError::::Unauthorized) if token.expired() => { + let token = self + .refresh_tokens() + .await + .map_err(AuthorizedError::::Refresh)?; + authorized::( + &self.public.client, + E::METHOD.into(), + &self.public.base, + endpoint.path(request), + &request, + &token, + ) + .await + } + result => result, + } + } +} diff --git a/api/src/schema/mod.rs b/api/src/schema/mod.rs new file mode 100644 index 0000000..29fe093 --- /dev/null +++ b/api/src/schema/mod.rs @@ -0,0 +1 @@ +pub mod sponds; diff --git a/api/src/schema/sponds.rs b/api/src/schema/sponds.rs new file mode 100644 index 0000000..ee2c814 --- /dev/null +++ b/api/src/schema/sponds.rs @@ -0,0 +1,57 @@ +// TODO: use crate::Id; +use crate::traits; + +// { +// "heading" : "Kraftraum putzen", +// "id" : "D678340FAA6341058E368AE2FB6082CA", +// "series" : false, +// "startTime" : "2026-11-07T08:00:00Z", +// "unanswered" : true, +// "updated" : 1770872490567 +// } +#[derive(serde::Deserialize, Debug)] +pub struct Spond { + pub id: crate::utils::X128, + pub updated: crate::utils::Timestamp, + pub start_time: chrono::DateTime, + pub heading: String, + #[serde(default)] + pub unanswered: bool, + pub series: bool, +} + +#[derive(serde::Deserialize, Debug, Default)] +pub struct Sponds(Vec); + +impl std::ops::Deref for Sponds { + type Target = [Spond]; + + fn deref(&self) -> &Self::Target { + &self.0 + } +} + +#[derive(serde::Serialize, Debug)] +pub struct Upcoming; + +impl traits::endpoint::Private for Sponds { + const METHOD: crate::Method = crate::Method::GET; + type Schema = Self; + + fn path(&self, _: &Upcoming) -> &str { + "/core/v1/sponds/upcoming" + } +} + +#[cfg(test)] +mod test { + use super::*; + + #[test] + fn decode_upcoming_schema() { + const DATA: &[u8] = include_bytes!("./sponds_upcoming.json"); + let bytes = bytes::Bytes::from_static(DATA); + let v: Sponds = >::deserialize(&Upcoming, &bytes).expect("VALID JSON"); + println!("{v:?}"); + } +} diff --git a/api/src/schema/sponds_upcoming.json b/api/src/schema/sponds_upcoming.json new file mode 100644 index 0000000..2787f86 --- /dev/null +++ b/api/src/schema/sponds_upcoming.json @@ -0,0 +1 @@ +[{"id":"AD033E0F90EF4A0E889C3E0EE4F7AACD","updated":1771395198239,"startTime":"2026-02-18T18:00:00Z","heading":"Abteilungsversammlung","series":false},{"id":"65CC28113E724113B1CE9AEC2BBF153E","updated":1771280224611,"startTime":"2026-02-19T13:00:00Z","heading":"Test","series":false},{"id":"5737EB7C021F498E878F14F4A9B39E63","updated":1771368685416,"startTime":"2026-02-19T18:45:00Z","heading":"Krafttraining Donnerstag","unanswered":true,"series":true},{"id":"81B37D845FB944E8A2652A8D425DB83E","updated":1771368696319,"startTime":"2026-02-20T17:30:00Z","heading":"Krafttraining Freitag","unanswered":true,"series":true},{"id":"0FD94BC6EE5243968BA068277DDAF5B1","updated":1771399515512,"startTime":"2026-02-21T10:45:00Z","heading":"Schwimmtraining Samstag","unanswered":true,"series":true},{"id":"4E6B81B750A34896AAD681E66A477AE4","updated":1770822214509,"startTime":"2026-02-22T09:00:00Z","heading":"MTB am Sonntag","series":true},{"id":"94F4351412E14788B1CE8020A43E22AE","updated":1771341718834,"startTime":"2026-02-22T17:25:00Z","heading":"Athletik-Training","unanswered":true,"series":true},{"id":"E1D9A6C5C1554070BA592C2752270906","updated":1770872493135,"startTime":"2026-02-23T18:45:00Z","heading":"Schwimmtraining Montag","series":true},{"id":"AC4C0EDD66FE4C29A66E6F637B5EF7AB","updated":1770872492350,"startTime":"2026-02-24T16:55:00Z","heading":"Lauftraining Intervalle Dienstag","series":true},{"id":"333BDC3E6DC04897B79334C887865DB1","updated":1770872490703,"startTime":"2026-02-25T18:25:00Z","heading":"Virtual Bike Training (ictrainer)","series":true},{"id":"CFB8D04583DA4F05977ABAB63821570E","updated":1770896398600,"startTime":"2026-02-26T18:45:00Z","heading":"Krafttraining Donnerstag","series":true},{"id":"D621B290A9B74F4CB5FFD4950F6EEBA4","updated":1770872491371,"startTime":"2026-02-26T18:55:00Z","heading":"Schwimmtraining Donnerstag","series":true},{"id":"547699FCE1944010A67A707399AE2A89","updated":1770872492706,"startTime":"2026-02-27T17:30:00Z","heading":"Krafttraining Freitag","series":true},{"id":"E06314BDF7804A9C83B6EE4E01DD4831","updated":1770809084109,"startTime":"2026-02-28T10:45:00Z","heading":"Schwimmtraining Samstag","series":true},{"id":"5360D7D37ED74F2D904B71BD4DA55B1F","updated":1770872492022,"startTime":"2026-03-01T09:00:00Z","heading":"MTB am Sonntag","series":true},{"id":"16A8E790B9324173B57819E7687DC19E","updated":1770872491695,"startTime":"2026-03-01T17:25:00Z","heading":"Athletik-Training","series":true},{"id":"4D9928E94A0445CB8A29510BC619890C","updated":1770872493135,"startTime":"2026-03-02T18:45:00Z","heading":"Schwimmtraining Montag","series":true},{"id":"6A99A0909F2346C796B14A011C613930","updated":1770872492350,"startTime":"2026-03-03T16:55:00Z","heading":"Lauftraining Intervalle Dienstag","series":true},{"id":"200FC5E4DCAB472EB96547CF468AC51E","updated":1770872490703,"startTime":"2026-03-04T18:25:00Z","heading":"Virtual Bike Training (ictrainer)","series":true},{"id":"25F4F0277E234C6BAE706A6828356D33","updated":1770896398600,"startTime":"2026-03-05T18:45:00Z","heading":"Krafttraining Donnerstag","series":true},{"id":"76416FBD18A4480E8FD8D0A09FE2F894","updated":1770872491371,"startTime":"2026-03-05T18:55:00Z","heading":"Schwimmtraining Donnerstag","series":true},{"id":"B67A85BEFCBB43BCB02E4A2B8E8BC5EE","updated":1770872492706,"startTime":"2026-03-06T17:30:00Z","heading":"Krafttraining Freitag","series":true},{"id":"E555E5F9355B429498E2650F409CDD4A","updated":1770571414141,"startTime":"2026-03-07T10:45:00Z","heading":"Schwimmtraining Samstag","series":true},{"id":"9628DFD73A0944C59819A5178AF5F912","updated":1770872492022,"startTime":"2026-03-08T09:00:00Z","heading":"MTB am Sonntag","series":true},{"id":"44DDB2ACA9554DD89DD41F1EDF0EF7D4","updated":1770872491695,"startTime":"2026-03-08T17:25:00Z","heading":"Athletik-Training","series":true},{"id":"2E7E5A07FF4946F2AD0588922E39A966","updated":1770872493135,"startTime":"2026-03-09T18:45:00Z","heading":"Schwimmtraining Montag","series":true},{"id":"6FE61FCEADBC40028CE048E78A38503B","updated":1770872492350,"startTime":"2026-03-10T16:55:00Z","heading":"Lauftraining Intervalle Dienstag","series":true},{"id":"CF0AA0DD1C0A43D681EEC7175F0B6030","updated":1770872490703,"startTime":"2026-03-11T18:25:00Z","heading":"Virtual Bike Training (ictrainer)","series":true},{"id":"E41A8DC5976E44CDBB944ABFABB939CF","updated":1770896398600,"startTime":"2026-03-12T18:45:00Z","heading":"Krafttraining Donnerstag","series":true},{"id":"F131CD46F80A42B9909D8E7F4018D8E1","updated":1770872491371,"startTime":"2026-03-12T18:55:00Z","heading":"Schwimmtraining Donnerstag","series":true},{"id":"A06ADBDC5FE547EA90B90A6886BF8FDF","updated":1770872492706,"startTime":"2026-03-13T17:30:00Z","heading":"Krafttraining Freitag","series":true},{"id":"2EF37B808AAE4C6AB0E053E31F381A75","updated":1770809084109,"startTime":"2026-03-14T10:45:00Z","heading":"Schwimmtraining Samstag","series":true},{"id":"FE0B1F8BC436438DA95E8F22A8FE6E61","updated":1770872492022,"startTime":"2026-03-15T09:00:00Z","heading":"MTB am Sonntag","series":true},{"id":"CF6FEAE6EB14471184D5831945455005","updated":1770872491695,"startTime":"2026-03-15T17:25:00Z","heading":"Athletik-Training","series":true},{"id":"41AB8F2F49D54878A596268E3131D5F4","updated":1770872493135,"startTime":"2026-03-16T18:45:00Z","heading":"Schwimmtraining Montag","series":true},{"id":"2590B6BFAFEF43E58C8040A127D5D119","updated":1770872492350,"startTime":"2026-03-17T16:55:00Z","heading":"Lauftraining Intervalle Dienstag","series":true},{"id":"922D71BF46F142CCAFEEE3933367ECD0","updated":1770872490703,"startTime":"2026-03-18T18:25:00Z","heading":"Virtual Bike Training (ictrainer)","series":true},{"id":"9E9960878AF847D08453E6618FCD1DE8","updated":1770896398600,"startTime":"2026-03-19T18:45:00Z","heading":"Krafttraining Donnerstag","series":true},{"id":"C3A14D8B724841079CD4AF2BEEBF452B","updated":1770872491371,"startTime":"2026-03-19T18:55:00Z","heading":"Schwimmtraining Donnerstag","series":true},{"id":"C43851BAF8914794935D0548BA7AF60D","updated":1770872492706,"startTime":"2026-03-20T17:30:00Z","heading":"Krafttraining Freitag","series":true},{"id":"AC95CBE05E8A4EB3BCCD8F4A180BA7FC","updated":1770809084109,"startTime":"2026-03-21T10:45:00Z","heading":"Schwimmtraining Samstag","series":true},{"id":"315A7320E90B493299341E5FBC4E3704","updated":1770872489876,"startTime":"2026-03-21T11:00:00Z","heading":"WK Run: Erlanger Winterwaldlauf","unanswered":true,"series":false},{"id":"7623A15FBB7C42F79A113F4428BC95D3","updated":1770872492022,"startTime":"2026-03-22T09:00:00Z","heading":"MTB am Sonntag","series":true},{"id":"420B2D3BCB9548DCB80FBAFDD13ED962","updated":1770872491695,"startTime":"2026-03-22T17:25:00Z","heading":"Athletik-Training","series":true},{"id":"0CA6E6E0EB65442F89641D2EE895CE09","updated":1770872493135,"startTime":"2026-03-23T18:45:00Z","heading":"Schwimmtraining Montag","series":true},{"id":"42064DCFCA4B49E98F9614AB3C7AABD0","updated":1770872492350,"startTime":"2026-03-24T16:55:00Z","heading":"Lauftraining Intervalle Dienstag","series":true},{"id":"1D49ABF2ED8D4C139675673800C62995","updated":1770872490703,"startTime":"2026-03-25T18:25:00Z","heading":"Virtual Bike Training (ictrainer)","series":true},{"id":"77346DC63E7B47FAA0328039F724B78F","updated":1770896398600,"startTime":"2026-03-26T18:45:00Z","heading":"Krafttraining Donnerstag","series":true},{"id":"6D23D3D0E9F2462180417BCA21E873CE","updated":1770872491371,"startTime":"2026-03-26T18:55:00Z","heading":"Schwimmtraining Donnerstag","series":true},{"id":"BB1F770E56954C4289213A09444DB76C","updated":1770872492706,"startTime":"2026-03-27T17:30:00Z","heading":"Krafttraining Freitag","series":true},{"id":"F0A208D28BF6436F87543E6324E58FC7","updated":1770809084109,"startTime":"2026-03-28T10:45:00Z","heading":"Schwimmtraining Samstag","series":true},{"id":"16FC02765C124B4EB950BA84D0C10069","updated":1770872492022,"startTime":"2026-03-29T08:00:00Z","heading":"MTB am Sonntag","series":true},{"id":"1410B75032484CF19E676C894C128B85","updated":1770872491695,"startTime":"2026-03-29T16:25:00Z","heading":"Athletik-Training","series":true},{"id":"F8A7A4616D154897AA7BD0F9C78C62FA","updated":1770872493135,"startTime":"2026-03-30T17:45:00Z","heading":"Schwimmtraining Montag","series":true},{"id":"3A9517F2FD80451F9E2DE185FF887DC6","updated":1770872492350,"startTime":"2026-03-31T15:55:00Z","heading":"Lauftraining Intervalle Dienstag","series":true},{"id":"BE005E971955419B872333C538A819D8","updated":1770872490703,"startTime":"2026-04-01T17:25:00Z","heading":"Virtual Bike Training (ictrainer)","series":true},{"id":"318130BCC9E6404BB90123E731F04808","updated":1770896398600,"startTime":"2026-04-02T17:45:00Z","heading":"Krafttraining Donnerstag","series":true},{"id":"41A78760E3C949379E6E8C786A4B4574","updated":1770872491371,"startTime":"2026-04-02T17:55:00Z","heading":"Schwimmtraining Donnerstag","series":true},{"id":"87538464E4AD4AE29D8E6A4E8FD01C8E","updated":1770872492706,"startTime":"2026-04-03T16:30:00Z","heading":"Krafttraining Freitag","series":true},{"id":"6EE6269B5A204CC0AE2B6A04732D4775","updated":1770809084109,"startTime":"2026-04-04T09:45:00Z","heading":"Schwimmtraining Samstag","series":true},{"id":"B6DDBD0298A0449783DFD2AE956A3D26","updated":1770872492022,"startTime":"2026-04-05T08:00:00Z","heading":"MTB am Sonntag","series":true},{"id":"FAB6FA8FB7554EC184B020001ADD8B94","updated":1770872491695,"startTime":"2026-04-05T16:25:00Z","heading":"Athletik-Training","series":true},{"id":"E4424B8088D54FD38A9D18B1F0BDD3EC","updated":1770872493135,"startTime":"2026-04-06T17:45:00Z","heading":"Schwimmtraining Montag","series":true},{"id":"A465565A012F4B3D8F0A723A3FEFCAA3","updated":1770872492350,"startTime":"2026-04-07T15:55:00Z","heading":"Lauftraining Intervalle Dienstag","series":true},{"id":"F142A604C9894396B10F22CAA01F8D7B","updated":1770872490703,"startTime":"2026-04-08T17:25:00Z","heading":"Virtual Bike Training (ictrainer)","series":true},{"id":"8EFED442D9444478A375DCFDBAFF0BDA","updated":1770896398600,"startTime":"2026-04-09T17:45:00Z","heading":"Krafttraining Donnerstag","series":true},{"id":"C27D9930301F4CC8B01CD8180BE0E10E","updated":1770872491371,"startTime":"2026-04-09T17:55:00Z","heading":"Schwimmtraining Donnerstag","series":true},{"id":"EE93FA9F675D401285AE2B501C31AED5","updated":1770872492706,"startTime":"2026-04-10T16:30:00Z","heading":"Krafttraining Freitag","series":true},{"id":"F94829E35A9B4A48A042646C8B658B01","updated":1770809084109,"startTime":"2026-04-11T09:45:00Z","heading":"Schwimmtraining Samstag","series":true},{"id":"4CA9B19A86204C2B8B47C469A4C54504","updated":1770872489114,"startTime":"2026-04-12T05:00:00Z","heading":"WK Run: Obermain-Marathon Bad Staffelstein","unanswered":true,"series":false},{"id":"2DB79CCDC3024429927D949DA45CCBE7","updated":1770872492022,"startTime":"2026-04-12T08:00:00Z","heading":"MTB am Sonntag","series":true},{"id":"D194BD466EE74247A10BC41CE9094CB0","updated":1770872491695,"startTime":"2026-04-12T16:25:00Z","heading":"Athletik-Training","series":true},{"id":"A141E76AA03345B3B32ED01FC602DEEA","updated":1770872493135,"startTime":"2026-04-13T17:45:00Z","heading":"Schwimmtraining Montag","series":true},{"id":"274FE98580DD413FB58E784DD3BD99B5","updated":1770872492350,"startTime":"2026-04-14T15:55:00Z","heading":"Lauftraining Intervalle Dienstag","series":true},{"id":"731D5094989147659BC937327B235FE7","updated":1770872490703,"startTime":"2026-04-15T17:25:00Z","heading":"Virtual Bike Training (ictrainer)","series":true},{"id":"D52B3730DD404254BE7B517640ED174E","updated":1770896398600,"startTime":"2026-04-16T17:45:00Z","heading":"Krafttraining Donnerstag","series":true},{"id":"C389610AC9BF4970A3AFBB36431FE585","updated":1770872491371,"startTime":"2026-04-16T17:55:00Z","heading":"Schwimmtraining Donnerstag","series":true},{"id":"FEA2E4FFC9E6452EAB7B289223724EC5","updated":1770872492706,"startTime":"2026-04-17T16:30:00Z","heading":"Krafttraining Freitag","series":true},{"id":"950F44DE301F4A548F541B0FE5ED399F","updated":1770809084109,"startTime":"2026-04-18T09:45:00Z","heading":"Schwimmtraining Samstag","series":true},{"id":"79A681BC733A477A88794B26A9D0093E","updated":1770872492022,"startTime":"2026-04-19T08:00:00Z","heading":"MTB am Sonntag","series":true},{"id":"D9310DC4BA274B6B90EBDF9D1E1F998F","updated":1770872491695,"startTime":"2026-04-19T16:25:00Z","heading":"Athletik-Training","series":true},{"id":"53243D99E9824746B6C32711AF5B6900","updated":1770872493135,"startTime":"2026-04-20T17:45:00Z","heading":"Schwimmtraining Montag","series":true},{"id":"47C16959F4774D3A8B36F9ECB42EE843","updated":1770872492350,"startTime":"2026-04-21T15:55:00Z","heading":"Lauftraining Intervalle Dienstag","series":true},{"id":"B3E387563B0745DEA0F720F3F26D66F6","updated":1770872490703,"startTime":"2026-04-22T17:25:00Z","heading":"Virtual Bike Training (ictrainer)","series":true},{"id":"07B9D6739D0B481EB7219F12461F3AC4","updated":1770896398600,"startTime":"2026-04-23T17:45:00Z","heading":"Krafttraining Donnerstag","series":true},{"id":"739F2147F8F7454CA339B14F7F9664E1","updated":1770872491371,"startTime":"2026-04-23T17:55:00Z","heading":"Schwimmtraining Donnerstag","series":true},{"id":"349B839EB9464198B62535EBC758E2FF","updated":1770872492706,"startTime":"2026-04-24T16:30:00Z","heading":"Krafttraining Freitag","series":true},{"id":"086E679C1E0B41F29025308C33B10B41","updated":1770809084109,"startTime":"2026-04-25T09:45:00Z","heading":"Schwimmtraining Samstag","series":true},{"id":"B15B6E51DD2749FCA773841632E66129","updated":1771358967671,"startTime":"2026-04-25T15:00:00Z","heading":"WK Swim & Run: Forcheim","unanswered":true,"series":false},{"id":"0E69CE6CFDE14A3DAB54E9CA9CA17469","updated":1770872492022,"startTime":"2026-04-26T08:00:00Z","heading":"MTB am Sonntag","series":true},{"id":"62ED6865F64A4AD0BF5C8F5DCB236B4D","updated":1770872491695,"startTime":"2026-04-26T16:25:00Z","heading":"Athletik-Training","series":true},{"id":"3BBC799F72094D809B5F08111449AA6D","updated":1770872493135,"startTime":"2026-04-27T17:45:00Z","heading":"Schwimmtraining Montag","series":true},{"id":"564E309B351F4084BA75C19CEE97869C","updated":1770872492350,"startTime":"2026-04-28T15:55:00Z","heading":"Lauftraining Intervalle Dienstag","series":true},{"id":"FC025A3D356F4E2D8BA00F4A8C958F58","updated":1770872490703,"startTime":"2026-04-29T17:25:00Z","heading":"Virtual Bike Training (ictrainer)","series":true},{"id":"6FA76E8266B141AB9A2668749132240C","updated":1770896398600,"startTime":"2026-04-30T17:45:00Z","heading":"Krafttraining Donnerstag","series":true},{"id":"4003D5F0A3504F93BE84AAC86CD9973A","updated":1770872491371,"startTime":"2026-04-30T17:55:00Z","heading":"Schwimmtraining Donnerstag","series":true},{"id":"27A1A2E7F78E427295E26B2A83658B2E","updated":1770872489399,"startTime":"2026-05-01T06:00:00Z","heading":"WK Bike: Eschborn-Frankfurt","unanswered":true,"series":false},{"id":"9710E49CF5454A139B47D577A0219984","updated":1770872492706,"startTime":"2026-05-01T16:30:00Z","heading":"Krafttraining Freitag","series":true},{"id":"8B2233B360524F7695B64148E432C68F","updated":1770809084109,"startTime":"2026-05-02T09:45:00Z","heading":"Schwimmtraining Samstag","series":true},{"id":"33C43197140F4E009549B7339278C2D2","updated":1770872492022,"startTime":"2026-05-03T08:00:00Z","heading":"MTB am Sonntag","series":true},{"id":"8F1843E801E544F4822F7F92AAA822DF","updated":1770872491695,"startTime":"2026-05-03T16:25:00Z","heading":"Athletik-Training","series":true},{"id":"3D3F7931216E46D69FED303DB3DAECE3","updated":1770872493135,"startTime":"2026-05-04T17:45:00Z","heading":"Schwimmtraining Montag","series":true},{"id":"CB9DB4AE1C684E9CA419798C2380D964","updated":1770872492350,"startTime":"2026-05-05T15:55:00Z","heading":"Lauftraining Intervalle Dienstag","series":true},{"id":"0298D709FE364907BB99E9F370D528BE","updated":1770896398600,"startTime":"2026-05-07T17:45:00Z","heading":"Krafttraining Donnerstag","series":true},{"id":"B25FE6D86FE241EF8CDBFEA9A1CCFDD2","updated":1770872491371,"startTime":"2026-05-07T17:55:00Z","heading":"Schwimmtraining Donnerstag","series":true},{"id":"403CA787543F4A83ABD9A23FC3A32F46","updated":1770872492706,"startTime":"2026-05-08T16:30:00Z","heading":"Krafttraining Freitag","series":true},{"id":"8DD4409556DE4F108A5179C436A00C34","updated":1770872489612,"startTime":"2026-05-09T04:00:00Z","heading":"WK Tri: Weiden Triathlon","unanswered":true,"series":false},{"id":"8180BAAD76A24DC2B94D4394CF21BD58","updated":1770809084109,"startTime":"2026-05-09T09:45:00Z","heading":"Schwimmtraining Samstag","series":true},{"id":"7AF03606CF784532A080EF75718517F3","updated":1770872492022,"startTime":"2026-05-10T08:00:00Z","heading":"MTB am Sonntag","series":true},{"id":"369E46341FAD44189558D1CA369A2D16","updated":1770872491695,"startTime":"2026-05-10T16:25:00Z","heading":"Athletik-Training","series":true},{"id":"14B080871B8541A4AB7F6B05D698D9E4","updated":1770872493135,"startTime":"2026-05-11T17:45:00Z","heading":"Schwimmtraining Montag","series":true},{"id":"CEFAEB27108548C08BDFAEC83B192086","updated":1770872492350,"startTime":"2026-05-12T15:55:00Z","heading":"Lauftraining Intervalle Dienstag","series":true},{"id":"9486F14CB6F9474F850465A13D84B1EC","updated":1770896398600,"startTime":"2026-05-14T17:45:00Z","heading":"Krafttraining Donnerstag","series":true},{"id":"DCDA1DA4197844B8BEFDCA921BC3FD27","updated":1770872491371,"startTime":"2026-05-14T17:55:00Z","heading":"Schwimmtraining Donnerstag","series":true},{"id":"A3A3A0C1C8B544C580993B3E4E53AF40","updated":1770872492706,"startTime":"2026-05-15T16:30:00Z","heading":"Krafttraining Freitag","series":true},{"id":"FC1C7372F16B4893942EB5910DA60C0F","updated":1770809084109,"startTime":"2026-05-16T09:45:00Z","heading":"Schwimmtraining Samstag","series":true},{"id":"5B35D8E10EFB4A34B6BE08C463CE3842","updated":1770872490042,"startTime":"2026-05-17T05:00:00Z","heading":"WK Tri: Schweinfurt MainCityTriathlon","unanswered":true,"series":false},{"id":"2DAA54C83EB54DF6B09FB09E4BC53244","updated":1770872492022,"startTime":"2026-05-17T08:00:00Z","heading":"MTB am Sonntag","series":true},{"id":"6E2047A76DDB4B9188DDDC1A046FB2BC","updated":1770872491695,"startTime":"2026-05-17T16:25:00Z","heading":"Athletik-Training","series":true},{"id":"DF4F4BA284604010A11EA7CAF81ECFF1","updated":1770872493135,"startTime":"2026-05-18T17:45:00Z","heading":"Schwimmtraining Montag","series":true},{"id":"2171B4D900134E729F13289C3C4FE0C8","updated":1770872492350,"startTime":"2026-05-19T15:55:00Z","heading":"Lauftraining Intervalle Dienstag","series":true},{"id":"62E1A57B3938448DA6561B2242ED5668","updated":1770896398600,"startTime":"2026-05-21T17:45:00Z","heading":"Krafttraining Donnerstag","series":true},{"id":"AA9279C8100F4BD49D39274BD5A1AD12","updated":1770872491371,"startTime":"2026-05-21T17:55:00Z","heading":"Schwimmtraining Donnerstag","series":true},{"id":"F05A75CA3B294EABB4E3526C0A02DED2","updated":1770872492706,"startTime":"2026-05-22T16:30:00Z","heading":"Krafttraining Freitag","series":true},{"id":"88312F5063ED4F3AA07323F3D22F5E16","updated":1770809084109,"startTime":"2026-05-23T09:45:00Z","heading":"Schwimmtraining Samstag","series":true},{"id":"A4334CCDF2B040118297049C0D882235","updated":1770872492022,"startTime":"2026-05-24T08:00:00Z","heading":"MTB am Sonntag","series":true},{"id":"128FF4E69E2D46FE9E31EF95AC276612","updated":1770872491695,"startTime":"2026-05-24T16:25:00Z","heading":"Athletik-Training","series":true},{"id":"BDAC8DB396E148769A2468CCFC617E1D","updated":1770872493135,"startTime":"2026-05-25T17:45:00Z","heading":"Schwimmtraining Montag","series":true},{"id":"900BE134E7CA4DEBB885F78348DF38CE","updated":1770872492350,"startTime":"2026-05-26T15:55:00Z","heading":"Lauftraining Intervalle Dienstag","series":true},{"id":"F8D90B5CD38744869FA539B6ED83D725","updated":1770896398600,"startTime":"2026-05-28T17:45:00Z","heading":"Krafttraining Donnerstag","series":true},{"id":"E79BF9D5E88A4075A26CD78A72BCC268","updated":1770872491371,"startTime":"2026-05-28T17:55:00Z","heading":"Schwimmtraining Donnerstag","series":true},{"id":"7FAD5D73F82341E988BA71A818EBDEC3","updated":1770872492706,"startTime":"2026-05-29T16:30:00Z","heading":"Krafttraining Freitag","series":true},{"id":"91B7AEEE784D4492900518284FF45255","updated":1770809084109,"startTime":"2026-05-30T09:45:00Z","heading":"Schwimmtraining Samstag","series":true},{"id":"83CEFA07B61D4D2C8905B47F9017A3A2","updated":1770872492022,"startTime":"2026-05-31T08:00:00Z","heading":"MTB am Sonntag","series":true},{"id":"DBD8EC4F7ED64608AC1F4250DCCF62E1","updated":1770872491695,"startTime":"2026-05-31T16:25:00Z","heading":"Athletik-Training","series":true},{"id":"AA55DF652913416D9C2698BA29EA694D","updated":1770872493135,"startTime":"2026-06-01T17:45:00Z","heading":"Schwimmtraining Montag","series":true},{"id":"0DC10A25F7FC4C2FA58CAE3D50300D4C","updated":1770872492350,"startTime":"2026-06-02T15:55:00Z","heading":"Lauftraining Intervalle Dienstag","series":true},{"id":"2F7021C8234C4C4B8B6B1B85E7572DDD","updated":1770896398600,"startTime":"2026-06-04T17:45:00Z","heading":"Krafttraining Donnerstag","series":true},{"id":"517C2489DFAD4D3090A95826E6768A92","updated":1770872491371,"startTime":"2026-06-04T17:55:00Z","heading":"Schwimmtraining Donnerstag","series":true},{"id":"1C131C2950DB481C93A9E19322BE1630","updated":1770872492706,"startTime":"2026-06-05T16:30:00Z","heading":"Krafttraining Freitag","series":true},{"id":"DE3D3C652E9848C8ADAE0B6DDFFA522E","updated":1770809084109,"startTime":"2026-06-06T09:45:00Z","heading":"Schwimmtraining Samstag","series":true},{"id":"DDB1D0E25E8844A59A52DB00884C48A7","updated":1770872489185,"startTime":"2026-06-07T04:00:00Z","heading":"WK Tri: Ironman Hamburg","unanswered":true,"series":false},{"id":"58D55ABC265F4D2EBA0D56A9F38EB866","updated":1770872492022,"startTime":"2026-06-07T08:00:00Z","heading":"MTB am Sonntag","series":true},{"id":"F7B66F6E50A145AA92DD4534C956A5CB","updated":1771358975548,"startTime":"2026-06-07T11:00:00Z","heading":"WK Tri: Bamberg Rattelsdorf-Ebing","unanswered":true,"series":false},{"id":"48FA244668A94754B088CF6FD833BC08","updated":1770872491695,"startTime":"2026-06-07T16:25:00Z","heading":"Athletik-Training","series":true},{"id":"FB7F2D0E11E04775BDF3A8C128982FB7","updated":1770872493135,"startTime":"2026-06-08T17:45:00Z","heading":"Schwimmtraining Montag","series":true},{"id":"5758BB1344984CDDB352356E12CCC00D","updated":1770872492350,"startTime":"2026-06-09T15:55:00Z","heading":"Lauftraining Intervalle Dienstag","series":true},{"id":"CB9D20D975D34D6EA5FBAD22309F48B2","updated":1770896398600,"startTime":"2026-06-11T17:45:00Z","heading":"Krafttraining Donnerstag","series":true},{"id":"62F6322CD41D45EABBA83E35DE93CBEA","updated":1770872491371,"startTime":"2026-06-11T17:55:00Z","heading":"Schwimmtraining Donnerstag","series":true},{"id":"8F57067F3B9F47DF8DF8C6C14F806758","updated":1770872492706,"startTime":"2026-06-12T16:30:00Z","heading":"Krafttraining Freitag","series":true},{"id":"4D5F35EAEC2441DCA2CDEFF1059A50FA","updated":1770809084109,"startTime":"2026-06-13T09:45:00Z","heading":"Schwimmtraining Samstag","series":true},{"id":"B8B6CF361F9A498C8BE6084A0C9EB0A4","updated":1770872489824,"startTime":"2026-06-13T11:00:00Z","heading":"WK Tri: Kallmünzer Triathlon","unanswered":true,"series":false},{"id":"DF952E9C2CE64830AD852C00874A51C2","updated":1770872489346,"startTime":"2026-06-14T05:00:00Z","heading":"WK Tri: Forcheim Triathlon","unanswered":true,"series":false},{"id":"EE7E37CB7555435DA37155ED2F2413F0","updated":1770872490149,"startTime":"2026-06-14T06:00:00Z","heading":"WK Tri: Ingolstadt Triathlon","unanswered":true,"series":false},{"id":"57F40409B2A54888A199B05B89E45915","updated":1770872492022,"startTime":"2026-06-14T08:00:00Z","heading":"MTB am Sonntag","series":true},{"id":"01ADB52C67794CA7BB6D69D26E67B2FC","updated":1770872491695,"startTime":"2026-06-14T16:25:00Z","heading":"Athletik-Training","series":true},{"id":"E57918F0FC134E069FAA880C6BC573C8","updated":1770872493135,"startTime":"2026-06-15T17:45:00Z","heading":"Schwimmtraining Montag","series":true},{"id":"863A72BCFCDE408BAE8A2DF82E78FEB1","updated":1770872492350,"startTime":"2026-06-16T15:55:00Z","heading":"Lauftraining Intervalle Dienstag","series":true},{"id":"3A2C5200466845EB91E3A0BBB4A8DBDF","updated":1770896398600,"startTime":"2026-06-18T17:45:00Z","heading":"Krafttraining Donnerstag","series":true},{"id":"41F1816B0FFE4778A518212D5DBC1756","updated":1770872491371,"startTime":"2026-06-18T17:55:00Z","heading":"Schwimmtraining Donnerstag","series":true},{"id":"0FD3581FF10C40D9BEAC883864AE8F54","updated":1770872492706,"startTime":"2026-06-19T16:30:00Z","heading":"Krafttraining Freitag","series":true},{"id":"B5C73942755A45C0A26735A74571B147","updated":1771358989948,"startTime":"2026-06-20T05:00:00Z","heading":"WK Tri: Rothsee Triathlon - Sprint & Schüler","unanswered":true,"series":false},{"id":"B665D8CAFDA84A4BA6417E19D4A5BBCF","updated":1770809084109,"startTime":"2026-06-20T09:45:00Z","heading":"Schwimmtraining Samstag","series":true},{"id":"E2AC39AA47D641BCA494EE5E1C2A6C9D","updated":1770872489559,"startTime":"2026-06-21T05:00:00Z","heading":"WK Tri: Rothsee Triathlon - Olympisch","unanswered":true,"series":false},{"id":"0F983EDD457D4078A83CABCDC225A382","updated":1770872492022,"startTime":"2026-06-21T08:00:00Z","heading":"MTB am Sonntag","series":true},{"id":"0C0247F25D5B4EEAAB046320CD9E7708","updated":1770872491695,"startTime":"2026-06-21T16:25:00Z","heading":"Athletik-Training","series":true},{"id":"089630E27C174208A09F2380CB90F9BE","updated":1770872493135,"startTime":"2026-06-22T17:45:00Z","heading":"Schwimmtraining Montag","series":true},{"id":"98C437703DE5486E8E64E94FF7B612F9","updated":1770872492350,"startTime":"2026-06-23T15:55:00Z","heading":"Lauftraining Intervalle Dienstag","series":true},{"id":"CEF688E08CFD4ABBA64AAA43AD77B353","updated":1770896398600,"startTime":"2026-06-25T17:45:00Z","heading":"Krafttraining Donnerstag","series":true},{"id":"A39BE570AF754754AA7F7282404D69E7","updated":1770872491371,"startTime":"2026-06-25T17:55:00Z","heading":"Schwimmtraining Donnerstag","series":true},{"id":"DED0BB679FE444F0AB31BED51185E471","updated":1770872492706,"startTime":"2026-06-26T16:30:00Z","heading":"Krafttraining Freitag","series":true},{"id":"C3E50842A4AC4CB8B02ACF8E560CC3BE","updated":1770809084109,"startTime":"2026-06-27T09:45:00Z","heading":"Schwimmtraining Samstag","series":true},{"id":"6BCB8683D912404F8ABF5C5DEF377782","updated":1770872489982,"startTime":"2026-06-28T04:00:00Z","heading":"WK Tri: Ironman Frankfurt ","unanswered":true,"series":false},{"id":"1C828D56FC3C4726959545C9C3AFF9DE","updated":1771358981104,"startTime":"2026-06-28T05:00:00Z","heading":"WK Tri: Trebgast Triathlon","unanswered":true,"series":false},{"id":"19133B8E5DB440DF99139D8E7C90B986","updated":1771359005002,"startTime":"2026-06-28T06:00:00Z","heading":"WK Tri: Herzoman","unanswered":true,"series":false},{"id":"193F5C0D4518407CB9875D8FC23B11BF","updated":1770872492022,"startTime":"2026-06-28T08:00:00Z","heading":"MTB am Sonntag","series":true},{"id":"AC7CDB68663849479CE411F70F0E50C8","updated":1770872491695,"startTime":"2026-06-28T16:25:00Z","heading":"Athletik-Training","series":true},{"id":"2FE40255B00F4115B152AC69EF6AAA31","updated":1770872493135,"startTime":"2026-06-29T17:45:00Z","heading":"Schwimmtraining Montag","series":true},{"id":"3C6EDD866CB143EFA92D16C67E879623","updated":1770872492350,"startTime":"2026-06-30T15:55:00Z","heading":"Lauftraining Intervalle Dienstag","series":true},{"id":"D15FC0223CE047E3AE3A978F17ED7BEF","updated":1770896398600,"startTime":"2026-07-02T17:45:00Z","heading":"Krafttraining Donnerstag","series":true},{"id":"D000D3A8DE074BFCB0BBAC0E39819038","updated":1770872491371,"startTime":"2026-07-02T17:55:00Z","heading":"Schwimmtraining Donnerstag","series":true},{"id":"7728A184DAE64011B18848BF9F956F8D","updated":1770872492706,"startTime":"2026-07-03T16:30:00Z","heading":"Krafttraining Freitag","series":true},{"id":"6236B4F4769647B39EBFDAE4112AB18B","updated":1770809084109,"startTime":"2026-07-04T09:45:00Z","heading":"Schwimmtraining Samstag","series":true},{"id":"0045063DCDAE4C879F67BFFD2643B51B","updated":1770872490199,"startTime":"2026-07-05T04:00:00Z","heading":"WK Tri: Challenge Roth","unanswered":true,"series":false},{"id":"E05E9905FBD048E693BEAD63D8072B7C","updated":1770872492022,"startTime":"2026-07-05T08:00:00Z","heading":"MTB am Sonntag","series":true},{"id":"985E53EF1A0740D5A397E17473E2DA7B","updated":1770872491695,"startTime":"2026-07-05T16:25:00Z","heading":"Athletik-Training","series":true},{"id":"85EFCF12E907492CB1C49BABB7A9F55C","updated":1770872493135,"startTime":"2026-07-06T17:45:00Z","heading":"Schwimmtraining Montag","series":true},{"id":"8069A7E5221749B8B4C55592CDA72DE4","updated":1770872492350,"startTime":"2026-07-07T15:55:00Z","heading":"Lauftraining Intervalle Dienstag","series":true},{"id":"A3DF460077DD45E8AC2D3A2524BC590C","updated":1770896398600,"startTime":"2026-07-09T17:45:00Z","heading":"Krafttraining Donnerstag","series":true},{"id":"4C47FA4C6CB4445ABB79CD4D29D59BBA","updated":1770872491371,"startTime":"2026-07-09T17:55:00Z","heading":"Schwimmtraining Donnerstag","series":true},{"id":"2FF7145EFE4C4AA4BE393D5CF5930EAE","updated":1770872492706,"startTime":"2026-07-10T16:30:00Z","heading":"Krafttraining Freitag","series":true},{"id":"2FF4B87D66664B75AEB8FB2BC21923BD","updated":1770809084109,"startTime":"2026-07-11T09:45:00Z","heading":"Schwimmtraining Samstag","series":true},{"id":"1F812F83763D4566ABBC0AAD50994716","updated":1770872490463,"startTime":"2026-07-12T05:00:00Z","heading":"WK Tri: Hof Triathlon","unanswered":true,"series":false},{"id":"13B16D2193714DFDA30D45C829FF52EF","updated":1770872492022,"startTime":"2026-07-12T08:00:00Z","heading":"MTB am Sonntag","series":true},{"id":"E2F769722C3B46E099D61710A589123C","updated":1770872491695,"startTime":"2026-07-12T16:25:00Z","heading":"Athletik-Training","series":true},{"id":"62389FE9A5AA4049B07288DC2B32B848","updated":1770872493135,"startTime":"2026-07-13T17:45:00Z","heading":"Schwimmtraining Montag","series":true},{"id":"91625CB3B14B429CB6EB88BE7FA09BF7","updated":1770872492350,"startTime":"2026-07-14T15:55:00Z","heading":"Lauftraining Intervalle Dienstag","series":true},{"id":"713614E7EBFB4B12B52297DC9DE4E9D8","updated":1770896398600,"startTime":"2026-07-16T17:45:00Z","heading":"Krafttraining Donnerstag","series":true},{"id":"F0E9D5686E5B4FFEAE958750558EC44F","updated":1770872491371,"startTime":"2026-07-16T17:55:00Z","heading":"Schwimmtraining Donnerstag","series":true},{"id":"8B950304FA5D49869901651C7D42FE00","updated":1770872492706,"startTime":"2026-07-17T16:30:00Z","heading":"Krafttraining Freitag","series":true},{"id":"8189C6AE2A18431491D32D6A90F13D66","updated":1770809084109,"startTime":"2026-07-18T09:45:00Z","heading":"Schwimmtraining Samstag","series":true},{"id":"493EC5E1B30F47E6BE94245A189856D8","updated":1770872492022,"startTime":"2026-07-19T08:00:00Z","heading":"MTB am Sonntag","series":true},{"id":"E8EBD45D473E45738ED53C60CA621944","updated":1770872491695,"startTime":"2026-07-19T16:25:00Z","heading":"Athletik-Training","series":true},{"id":"8F009AD5ECF14302A57F2D9611A0C63D","updated":1770872493135,"startTime":"2026-07-20T17:45:00Z","heading":"Schwimmtraining Montag","series":true},{"id":"E87E3974791B4DCA8E9123ABB140AC72","updated":1770872492350,"startTime":"2026-07-21T15:55:00Z","heading":"Lauftraining Intervalle Dienstag","series":true},{"id":"2708F93B29ED49D8941B9C05D29A7D67","updated":1770896398600,"startTime":"2026-07-23T17:45:00Z","heading":"Krafttraining Donnerstag","series":true},{"id":"3700734186F044038474C2A600EEF4F3","updated":1770872491371,"startTime":"2026-07-23T17:55:00Z","heading":"Schwimmtraining Donnerstag","series":true},{"id":"0D0333358AD04C33908DE97DF042F019","updated":1770872492706,"startTime":"2026-07-24T16:30:00Z","heading":"Krafttraining Freitag","series":true},{"id":"3C48E9130D2140FA940BD32F6D86C55F","updated":1770809084109,"startTime":"2026-07-25T09:45:00Z","heading":"Schwimmtraining Samstag","series":true},{"id":"3597C7A9DFEE4D3990F4364CDBD48854","updated":1770872490251,"startTime":"2026-07-26T05:00:00Z","heading":"WK Tri: Erlanger Triathlon","unanswered":true,"series":false},{"id":"94D76E20515341299C16C2D5558E1294","updated":1770872492022,"startTime":"2026-07-26T08:00:00Z","heading":"MTB am Sonntag","series":true},{"id":"48F4A73A24BB4746B8131688789DE579","updated":1770872491695,"startTime":"2026-07-26T16:25:00Z","heading":"Athletik-Training","series":true},{"id":"608334E080854CCE840F6378A5CD84C2","updated":1770872493135,"startTime":"2026-07-27T17:45:00Z","heading":"Schwimmtraining Montag","series":true},{"id":"2412DB8A6556427EB8BCE4F349E13037","updated":1770872492350,"startTime":"2026-07-28T15:55:00Z","heading":"Lauftraining Intervalle Dienstag","series":true},{"id":"462D25DFBC2F4384A679CDF8D5C0691B","updated":1770896398600,"startTime":"2026-07-30T17:45:00Z","heading":"Krafttraining Donnerstag","series":true},{"id":"2DBF2336730D43AAAC58E914837C5F0E","updated":1770872491371,"startTime":"2026-07-30T17:55:00Z","heading":"Schwimmtraining Donnerstag","series":true},{"id":"ACC91422FAD349F48557F287B27FBD51","updated":1770872492706,"startTime":"2026-07-31T16:30:00Z","heading":"Krafttraining Freitag","series":true},{"id":"FDAED0C615AD4E3BAA836247D37DE6AF","updated":1770809084109,"startTime":"2026-08-01T09:45:00Z","heading":"Schwimmtraining Samstag","series":true},{"id":"8CB986167D8B4E9F916BBF3C9DDBDB3C","updated":1770872492022,"startTime":"2026-08-02T08:00:00Z","heading":"MTB am Sonntag","series":true},{"id":"7A1E9CA2F54C470D89ED3A18A02ADBBA","updated":1770872491695,"startTime":"2026-08-02T16:25:00Z","heading":"Athletik-Training","series":true},{"id":"C9D25BB4931C4E4F90465370177ECE64","updated":1770872493135,"startTime":"2026-08-03T17:45:00Z","heading":"Schwimmtraining Montag","series":true},{"id":"120B893E4D1E496698FDEF4074887968","updated":1770872492350,"startTime":"2026-08-04T15:55:00Z","heading":"Lauftraining Intervalle Dienstag","series":true},{"id":"F49DC332CF024F62B4B3E0A0A3488580","updated":1770896398600,"startTime":"2026-08-06T17:45:00Z","heading":"Krafttraining Donnerstag","series":true},{"id":"94677D04655144E985176DE32668457E","updated":1770872491371,"startTime":"2026-08-06T17:55:00Z","heading":"Schwimmtraining Donnerstag","series":true},{"id":"883E2D725D46422793D2A109908495E4","updated":1770872492706,"startTime":"2026-08-07T16:30:00Z","heading":"Krafttraining Freitag","series":true},{"id":"F4748051C0EA47F6B7EF8B63E75AFF3A","updated":1770809084109,"startTime":"2026-08-08T09:45:00Z","heading":"Schwimmtraining Samstag","series":true},{"id":"86171BB304DB48CBB5A390CA0A55A1ED","updated":1770872489291,"startTime":"2026-08-09T05:00:00Z","heading":"WK Tri: Nürnberg Triathlon","unanswered":true,"series":false},{"id":"FF6CEF5D64474351818A14271F7C1B46","updated":1770872492022,"startTime":"2026-08-09T08:00:00Z","heading":"MTB am Sonntag","series":true},{"id":"C5BC881DDCA348DA833D9D484F0EEB39","updated":1770872491695,"startTime":"2026-08-09T16:25:00Z","heading":"Athletik-Training","series":true},{"id":"BDC179CB3C764A2690B13E2058D3EEAF","updated":1770872493135,"startTime":"2026-08-10T17:45:00Z","heading":"Schwimmtraining Montag","series":true},{"id":"368B2DC59B324FBFA79395A96A19DB75","updated":1770872492350,"startTime":"2026-08-11T15:55:00Z","heading":"Lauftraining Intervalle Dienstag","series":true},{"id":"B0DDD8947F464018BC8DD23055EAFBD7","updated":1770896398600,"startTime":"2026-08-13T17:45:00Z","heading":"Krafttraining Donnerstag","series":true},{"id":"DA28C1995394492CBD9BE0A6C30A09D7","updated":1770872491371,"startTime":"2026-08-13T17:55:00Z","heading":"Schwimmtraining Donnerstag","series":true},{"id":"83242F9071E34B34BE5005755F1920BF","updated":1770931780528,"startTime":"2026-08-14T16:30:00Z","heading":"Krafttraining Freitag","series":true},{"id":"341C5932BF674488B2790DB969B15504","updated":1770978099780,"startTime":"2026-08-15T09:45:00Z","heading":"Schwimmtraining Samstag","series":true},{"id":"AA88F8A874DA4775A61E029631BEE55D","updated":1771056456282,"startTime":"2026-08-16T08:00:00Z","heading":"MTB am Sonntag","series":true},{"id":"FA4BCD9A656A42C3BE01B80FF50D0EBE","updated":1771086954334,"startTime":"2026-08-16T16:25:00Z","heading":"Athletik-Training","series":true},{"id":"302E7BCFAF674BBCA0EE77B0D119158E","updated":1771196256828,"startTime":"2026-08-17T17:45:00Z","heading":"Schwimmtraining Montag","series":true},{"id":"C9E5B5C2D5694F82B1F3DB1BDC0B5CBD","updated":1771306178424,"startTime":"2026-08-18T15:55:00Z","heading":"Lauftraining Intervalle Dienstag","series":true},{"id":"16EA34002E0A4AA29548881CC3FF0FD5","updated":1770872489772,"startTime":"2026-08-23T05:00:00Z","heading":"WK Tri: Allgäu Triathlon","unanswered":true,"series":false},{"id":"7686681ADE904FAFAEF03D24BA225E4C","updated":1770872490305,"startTime":"2026-08-30T05:00:00Z","heading":"WK Tri: Brombachsee Triathlon","unanswered":true,"series":false},{"id":"888EA479199B4FF588BD8DCD1D5BBAFF","updated":1770872489508,"startTime":"2026-09-06T19:00:00Z","heading":"WK Run: Fränkische Schweiz-Marathon","unanswered":true,"series":false},{"id":"C3446FA49A39439AAFB63822C7117153","updated":1771359026096,"startTime":"2026-09-13T05:00:00Z","heading":"WK Tri: Seenland Triathlon","unanswered":true,"series":false},{"id":"2123C68846F94E4EAA30C2153124A231","updated":1770872489927,"startTime":"2026-09-20T08:00:00Z","heading":"WK Run: Tegernseelauf","unanswered":true,"series":false},{"id":"43C7F527BE1441C0A4CE29E566F49516","updated":1771359109568,"startTime":"2026-09-27T05:00:00Z","heading":"WK Run: Marathon Berlin","unanswered":true,"series":false},{"id":"263B93B766824638A85128ED22D3FB98","updated":1770872490514,"startTime":"2026-10-11T05:00:00Z","heading":"WK Run: München Marathon","unanswered":true,"series":false},{"id":"D678340FAA6341058E368AE2FB6082CA","updated":1770872490567,"startTime":"2026-11-07T08:00:00Z","heading":"Kraftraum putzen","unanswered":true,"series":false}] diff --git a/api/src/traits/authentication/login.rs b/api/src/traits/authentication/login.rs new file mode 100644 index 0000000..15c6559 --- /dev/null +++ b/api/src/traits/authentication/login.rs @@ -0,0 +1 @@ +pub trait Credentials: super::super::Request {} diff --git a/api/src/traits/authentication/mod.rs b/api/src/traits/authentication/mod.rs new file mode 100644 index 0000000..d86da16 --- /dev/null +++ b/api/src/traits/authentication/mod.rs @@ -0,0 +1,2 @@ +pub mod login; +pub use login::Credentials; diff --git a/api/src/traits/authorization.rs b/api/src/traits/authorization.rs new file mode 100644 index 0000000..30aa41b --- /dev/null +++ b/api/src/traits/authorization.rs @@ -0,0 +1,11 @@ +pub trait Authorization: private::Seal {} + +mod private { + use crate::authorization::{False, True}; + pub trait Seal {} + + impl Seal for True {} + impl Seal for False {} +} + +impl Authorization for T {} diff --git a/api/src/traits/client.rs b/api/src/traits/client.rs new file mode 100644 index 0000000..e27b561 --- /dev/null +++ b/api/src/traits/client.rs @@ -0,0 +1,80 @@ +use super::{Authorization, Endpoint, Request, Schema, endpoint}; +use crate::{authorization, authentication, error}; +use async_trait::async_trait; + +pub trait Client: Public + Private {} + +impl Client for C {} + +#[async_trait] +pub trait Handler, R: Request, A: Authorization> { + type Error: std::error::Error; + + async fn execute(&self, endpoint: &E, request: &R) -> Result; +} + +#[async_trait] +pub trait Authenticator: Public { + type Private: Private; + + fn with_tokens(&self, tokens: authentication::Tokens) -> Self::Private; + + async fn authenticate(&self, endpoint: &E, request: &R) -> Result::Error, >::Error>> + where + E: endpoint::Public + Sync, + R: Request + Sync, + { + let tokens = self.execute(endpoint, request).await?; + Ok(self.with_tokens(tokens)) + } +} + +#[async_trait] +pub trait Public { + type Error: std::error::Error + Send; + + async fn execute( + &self, + endpoint: &E, + request: &R, + ) -> Result>::Error>> + where + E: endpoint::Public + Sync, + R: Request + Sync; +} + +#[async_trait] +impl + Sync, R: Request + Sync> + Handler for P +{ + type Error = error::api::Public>::Error>; + + async fn execute(&self, endpoint: &E, request: &R) -> Result { + self.execute(endpoint, request).await + } +} + +#[async_trait] +pub trait Private { + type Error: std::error::Error + Send; + + async fn execute( + &self, + endpoint: &E, + request: &R, + ) -> Result>::Error>> + where + E: endpoint::Private + Sync, + R: Request + Sync; +} + +#[async_trait] +impl + Sync, R: Request + Sync> + Handler for P +{ + type Error = error::api::Private>::Error>; + + async fn execute(&self, endpoint: &E, request: &R) -> Result { + self.execute(endpoint, request).await + } +} diff --git a/api/src/traits/endpoint.rs b/api/src/traits/endpoint.rs new file mode 100644 index 0000000..d8aef19 --- /dev/null +++ b/api/src/traits/endpoint.rs @@ -0,0 +1,53 @@ +use super::{Authorization, Request, Schema}; +use crate::{Method, authorization}; + +pub trait Endpoint: private::Seal { + const METHOD: Method; + type Schema: Schema; + + fn path(&self, request: &R) -> &str; +} + +/// A Endpoint with required authorization +pub trait Private { + const METHOD: Method; + type Schema: Schema; + + fn path(&self, request: &R) -> &str; +} + +impl, R: Request> Endpoint for T { + const METHOD: Method = T::METHOD; + type Schema = T::Schema; + + fn path(&self, request: &R) -> &str { + self.path(request) + } +} + +/// A Endpoint without required authorization +pub trait Public { + const METHOD: Method; + type Schema: Schema; + + fn path(&self, request: &R) -> &str; +} + +impl, R: Request> Endpoint for T { + const METHOD: Method = T::METHOD; + type Schema = T::Schema; + + fn path(&self, request: &R) -> &str { + self.path(request) + } +} + +mod private { + use super::*; + + /// Seal the Endpoint dependency + pub trait Seal {} + + impl> Seal for P {} + impl> Seal for P {} +} diff --git a/api/src/traits/id.rs b/api/src/traits/id.rs new file mode 100644 index 0000000..956ac12 --- /dev/null +++ b/api/src/traits/id.rs @@ -0,0 +1,22 @@ +use super::{ + client::Handler, + Schema, + Endpoint, +}; +use crate::{ + Id, + authorization, +}; +use async_trait::async_trait; + +#[async_trait] +pub trait Marker: Schema> + Endpoint, authorization::True, Schema=Self> + std::fmt::Debug { + async fn resolve, authorization::True> + Sync>(&self, id: &Id, handler: &H) -> Result; +} + +#[async_trait] +impl> + Endpoint, authorization::True, Schema=T> + Sync + std::fmt::Debug> Marker for T { + async fn resolve, authorization::True> + Sync>(&self, id: &Id, handler: &H) -> Result { + handler.execute(&self, id).await + } +} diff --git a/api/src/traits/mod.rs b/api/src/traits/mod.rs new file mode 100644 index 0000000..93881d9 --- /dev/null +++ b/api/src/traits/mod.rs @@ -0,0 +1,17 @@ +pub mod authentication; +pub mod authorization; +pub mod client; +pub mod endpoint; +pub mod id; +pub mod request; +pub mod schema; + +pub use authentication::Credentials; +pub use authorization::Authorization; +pub use client::Client; +pub use endpoint::Endpoint; +pub use request::Request; +pub use schema::Schema; + +//#[cfg(test)] +//mod test; diff --git a/api/src/traits/request.rs b/api/src/traits/request.rs new file mode 100644 index 0000000..a7f8a19 --- /dev/null +++ b/api/src/traits/request.rs @@ -0,0 +1,5 @@ +use serde::Serialize; + +pub trait Request: Serialize + std::fmt::Debug {} + +impl Request for T {} diff --git a/api/src/traits/schema.rs b/api/src/traits/schema.rs new file mode 100644 index 0000000..1524861 --- /dev/null +++ b/api/src/traits/schema.rs @@ -0,0 +1,17 @@ +use super::Request; +use bytes::Bytes; +use serde::de::DeserializeOwned; + +pub trait Schema: std::fmt::Debug + Send + Sized { + type Error: std::error::Error + Send; + + fn deserialize(request: &R, response: &Bytes) -> Result; +} + +impl Schema for T { + type Error = serde_json::Error; + + fn deserialize(_: &R, response: &Bytes) -> Result { + serde_json::from_slice(&response) + } +} diff --git a/api/src/traits/test.rs b/api/src/traits/test.rs new file mode 100644 index 0000000..d13987c --- /dev/null +++ b/api/src/traits/test.rs @@ -0,0 +1,53 @@ +use async_trait::async_trait; + +struct Private; +struct Endpoint; +#[derive(serde::Serialize)] +struct Request; +#[derive(serde::Deserialize)] +struct Schema; + +#[async_trait] +impl super::client::Private for Private { + type Error = error::Private; + + async fn execute(&self, _: &E, _: &R) -> Result>::Error>> + where + E: super::endpoint::Private, + R: super::Request + Sync, + { + Err(error::Private::Unauthorized) + } +} + +impl super::endpoint::Private for Endpoint { + const METHOD: reqwest::Method = reqwest::Method::GET; + type Schema = Schema; + + fn path(&self, _: &Request) -> &str { + "/core/v1/endpoint/private" + } +} + +mod error { + use thiserror::Error; + + #[derive(Debug, Error)] + pub enum Private { + #[error("unauthorized")] + Unauthorized, + } +} + +#[tokio::test] +async fn private_endpoint() { + use super::client::Private; + let client = Private; + let request = Request; + let endpoint = Endpoint; + let result = match client.execute(&endpoint, &request).await { + Err(error::Private::Unauthorized) => false, + _ => true, + }; + assert_eq!(result, true) +} diff --git a/api/src/utils/mod.rs b/api/src/utils/mod.rs new file mode 100644 index 0000000..1e4bbdc --- /dev/null +++ b/api/src/utils/mod.rs @@ -0,0 +1,5 @@ +mod x128; +pub use x128::X128; + +mod timestamp; +pub use timestamp::Timestamp; diff --git a/api/src/utils/timestamp.rs b/api/src/utils/timestamp.rs new file mode 100644 index 0000000..097b5fe --- /dev/null +++ b/api/src/utils/timestamp.rs @@ -0,0 +1,2 @@ +#[derive(Debug, serde::Deserialize)] +pub struct Timestamp(u64); diff --git a/api/src/utils/x128.rs b/api/src/utils/x128.rs new file mode 100644 index 0000000..af6daef --- /dev/null +++ b/api/src/utils/x128.rs @@ -0,0 +1,78 @@ +use serde::{Serialize, Deserialize, Serializer, Deserializer}; +use std::ops::Deref; +use std::str::FromStr; +use std::fmt; + +/// Wrapper for u128 that serializes/deserializes as 32-charachter hex +#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash, Default)] +pub struct X128(u128); + +#[derive(Debug, thiserror::Error)] +pub enum Error { + #[error("invalid length: {0}")] + Length(usize), + + #[error("parser error: {0}")] + Parser(#[from] std::num::ParseIntError), +} + +impl X128 { + /// construct a new value + pub fn new(value: u128) -> Self { + Self(value) + } + + /// access the inner value explicitely + pub fn value(&self) -> u128 { + self.0 + } +} + +impl FromStr for X128 { + type Err = Error; + + fn from_str(s: &str) -> Result { + match s.len() { + 32 => u128::from_str_radix(s, 16) + .map(Self::new) + .map_err(Error::Parser), + len => Err(Error::Length(len)), + } + } +} + +impl TryFrom<&str> for X128 { + type Error = Error; + + fn try_from(s: &str) -> Result { + Self::from_str(s) + } +} + +impl Deref for X128 { + type Target = u128; + + fn deref(&self) -> &u128 { + &self.0 + } +} + +impl fmt::Display for X128 { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + write!(f, "{:032x}", self.0) + } +} + +impl Serialize for X128 { + fn serialize(&self, serializer: S) -> Result { + serializer.serialize_str(&self.to_string()) + } +} + +impl<'de> Deserialize<'de> for X128 { + fn deserialize>(deserializer: D) -> Result { + let s = String::deserialize(deserializer)?; + + Self::from_str(&s).map_err(serde::de::Error::custom) + } +} diff --git a/flake.lock b/flake.lock new file mode 100644 index 0000000..cad5b4b --- /dev/null +++ b/flake.lock @@ -0,0 +1,25 @@ +{ + "nodes": { + "nixpkgs": { + "locked": { + "lastModified": 1770843696, + "narHash": "sha256-LovWTGDwXhkfCOmbgLVA10bvsi/P8eDDpRudgk68HA8=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "2343bbb58f99267223bc2aac4fc9ea301a155a16", + "type": "github" + }, + "original": { + "id": "nixpkgs", + "type": "indirect" + } + }, + "root": { + "inputs": { + "nixpkgs": "nixpkgs" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/flake.nix b/flake.nix new file mode 100644 index 0000000..635f84f --- /dev/null +++ b/flake.nix @@ -0,0 +1,59 @@ +{ + outputs = { nixpkgs, ... }: let + spond = { rustPlatform, rustfmt, clippy, pkg-config, openssl, ... }: rustPlatform.buildRustPackage { + pname = "spond"; + version = "0.0.0"; + + src = ./.; + cargoLock.lockFile = ./Cargo.lock; + nativeBuildInputs = [ + pkg-config + ]; + propagatedBuildInputs = [ + openssl.dev + ]; + }; + + allpkgs = system: pkgs: pkgs.extend (_: _: nixpkgs.lib.attrsets.filterAttrs (name: _: name != "default") (packages system pkgs)); + + packages = system: pkgs': let + pkgs = allpkgs system pkgs'; + in { + default = pkgs.spond; + spond = pkgs.callPackage spond {}; + }; + + devShells = system: pkgs': let + pkgs = allpkgs system pkgs'; + in builtins.mapAttrs (devShell pkgs) (packages system pkgs'); + + devShell = pkgs: name: pkg: pkgs.mkShell { + buildInputs = with pkgs; [ + cargo + cargo-machete + cargo-workspaces + cargo-unused-features + cargo-udeps + cargo-audit + cargo-diet + cargo-duplicates + cargo-flamegraph + clippy + + (python3.withPackages (py: [ py.pyyaml ])) + + rustc + rustfmt + ] ++ pkg.buildInputs; + + nativeBuildInputs = pkg.nativeBuildInputs; + + shellHook = '' + printf 'Dev shell for %s ready!\n' '${pkg.name}' + ''; + }; + in { + packages = builtins.mapAttrs packages nixpkgs.legacyPackages; + devShells = builtins.mapAttrs devShells nixpkgs.legacyPackages; + }; +} diff --git a/turnerbund/:w b/turnerbund/:w new file mode 100644 index 0000000..4a1c242 --- /dev/null +++ b/turnerbund/:w @@ -0,0 +1,231 @@ +use tracing_subscriber::prelude::*; +use tracing_subscriber::{fmt, EnvFilter}; +pub use tracing::{error, warn, info, debug, trace}; + +#[cfg(feature="disabled")] +mod disabled { + +//mod select; +//use select::WeightedSet; +mod api; +mod utils; +mod id; +mod user; + +use tracing_subscriber::prelude::*; +use tracing_subscriber::{fmt, EnvFilter}; +pub use tracing::{error, warn, info, debug, trace}; + +use rand::prelude::*; +use std::collections::HashSet; +use std::collections::HashMap; + +#[derive(Debug, thiserror::Error)] +pub enum NoError {} + +#[derive(Debug, Clone, Copy, Eq, Hash, PartialEq, PartialOrd, Ord)] +struct UserID(u128); + +impl std::fmt::Display for UserID { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + write!(f, "UserID({})", self.0) + } +} + +#[derive(Default)] +struct Participants(Vec<(UserID, usize)>); + +trait Event { + fn registered(&self, uid: UserID) -> bool; + fn participated(&self, uid: UserID) -> bool { self.registered(uid) } +} + +#[derive(Clone)] +struct MockEvent { + id: usize, + users: HashMap, +} + +impl MockEvent { + fn new(id: usize, registrants: HashSet, participants: HashSet) -> Self { + let users = registrants.into_iter() + .map(|uid| (uid, participants.contains(&uid))) + .collect(); + Self { id, users } + } +} + +impl std::fmt::Display for MockEvent { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + write!(f, "MockEvent{}({:?})", self.id, self.users) + } +} + +impl Event for &MockEvent { + fn registered(&self, uid: UserID) -> bool { + self.users.get(&uid).is_some() + } + + fn participated(&self, uid: UserID) -> bool { + self.users.get(&uid).is_some_and(|participated|*participated) + } +} + +impl Participants { + pub fn add(mut self, uid: UserID) -> Self { + self.0.push((uid, 1)); + self + } + + pub fn select(mut self, history: H, rng: &mut impl Rng, count: usize) + -> HashSet + where + H: Iterator, + ::Item: Event, + { + for event in history { + let mut modified = false; + for item in self.0.iter_mut() { + if event.registered(item.0) && !event.participated(item.0) { + modified = true; + item.1 += 1; + } + } + if !modified { + break; + } + } + + println!("{:?}", self.0); + + self.0.sample_weighted(rng, count, |item: &'_ (_, usize)| item.1 as f64) + .unwrap() + .map(|item| item.0) + .collect() + } +} + +async fn connect<'a, I: spond::auth::Identifier + From<&'a str>>(id: &'a str) -> Result { + let pw = std::env::var("SPOND_PASSWORD").expect("a password is required in SPOND_PASSWORD"); + let id: I = id.into(); + let auth = spond::auth::Login::new(id, pw); + let client = spond::Api::new(auth).await?; + Ok(client) +} + +async fn main() -> anyhow::Result<()> { + let filter = EnvFilter::try_from_default_env() + .unwrap_or_else(|_| EnvFilter::new("info")); + tracing_subscriber::registry() + .with(fmt::layer().pretty()) + .with(filter) + .init(); + + error!("Error Message"); + warn!("Warn Message"); + info!("Info Message"); + debug!("Debug Message"); + trace!("Trace Message"); + + let client = if let Ok(email) = std::env::var("SPOND_EMAIL") { + connect::(&email).await? + } else if let Ok(phone) = std::env::var("SPOND_PHONE") { + connect::(&phone).await? + } else { + panic!("no credentials provided"); + }; + + let _ = client; + + + let users = (0..25).map(UserID).collect::>(); + let mut events = Vec::new(); + + for id in 0..5 { + let mut rng = rand::rng(); + let want = users.iter().filter(|_| (&mut rng).random_bool(0.75)).map(|id|id.clone()).collect::>(); + + let mut participants = Participants::default(); + for uid in want.iter() { + participants = participants.add(*uid); + } + + let participants = participants.select(events.iter().rev(), &mut rng, 12); + let event = MockEvent::new(id, want, participants); + println!("{event}"); + events.push(event); + } + + for uid in users.into_iter() { + let (registered, participated) = events.iter() + .fold((0, 0), |(registered, participated), event| { + let registered = registered + if event.registered(uid) { 1 } else { 0 }; + let participated = participated + if event.participated(uid) { 1 } else { 0 }; + (registered, participated) + }); + + println!("{uid}: ({participated}/{registered}) {:.2}%", + (participated as f64) / (registered as f64) * 100f64); + } + + Ok(()) +} +} + +fn tracing_setup(filter: &str) { + let filter = EnvFilter::try_from_default_env() + .unwrap_or_else(|_| EnvFilter::new(filter)); + + tracing_subscriber::registry() + .with(fmt::layer().pretty()) + .with(filter) + .init(); +} + +async fn connect(authenticator: A, credentials: C) -> Result::Error, >::Error>> { + let auth = spond::authentication::Login; + + authenticator.authenticate(&auth, &credentials).await +} + +#[derive(serde::Deserialize)] +struct Spond() + +#[derive(serde::Deserialize)] +struct Sponds(Vec); + +impl spond::traits::endpoint::Private for Sponds { + const METHOD: spond::Method = spond::Method::GET; + type Schema = Self; + + fn path(&self, _: &SpodsW +} + +#[derive(serde::Seralize)] +struct SpondsQuery; + +#[tokio::main] +async fn main() { + tracing_setup("info"); + + #[cfg(feature="disabled")] + disabled::main().await; + + error!("Error Message"); + warn!("Warn Message"); + info!("Info Message"); + debug!("Debug Message"); + trace!("Trace Message"); + + let pw = std::env::var("SPOND_PASSWORD").expect("a password is required in SPOND_PASSWORD"); + let client = spond::reqwest::Public::new().expect("public client"); + let client = if let Ok(email) = std::env::var("SPOND_EMAIL") { + connect(client, spond::authentication::login::Email::new(&email, &pw)).await + } else if let Ok(phone) = std::env::var("SPOND_PHONE") { + connect(client, spond::authentication::login::Phone::new(&phone, &pw)).await + } else { + panic!("no credentials provided"); + }; + + let _ = client.execute(; +} diff --git a/turnerbund/Cargo.toml b/turnerbund/Cargo.toml new file mode 100644 index 0000000..678a760 --- /dev/null +++ b/turnerbund/Cargo.toml @@ -0,0 +1,25 @@ +[package] +name = "turnerbund" +version = "0.1.0" +edition = "2024" + +[features] +disabled=[] + +[dependencies] +spond = { path = "../api", features = [ "reqwest" ] } +anyhow = "1.0.101" +async-trait = "0.1.89" +bon = "3.9.0" +chrono = { version = "0.4.43", features = ["serde"] } +http = "1.4.0" +rand = "0.10.0" +#reqwest = { version = "0.13.2", features = ["json", "zstd", "brotli", "gzip", "deflate"] } +reqwest-middleware = { version = "0.5.1", features = ["json", "http2"] } +serde = { version = "1.0.228", features = ["derive"] } +serde_json = "1.0.149" +thiserror = "2.0.18" +tokio = { version = "1.49.0", features = ["macros", "rt-multi-thread", "tracing"] } +tracing = { version = "0.1.44", features = ["log"] } +tracing-subscriber = { version = "0.3.22", features = ["serde", "json", "tracing", "env-filter", "chrono"] } +url = "2.5.8" diff --git a/turnerbund/src/api/api.rs b/turnerbund/src/api/api.rs new file mode 100644 index 0000000..dee5917 --- /dev/null +++ b/turnerbund/src/api/api.rs @@ -0,0 +1,201 @@ +use super::{ + Request, + error, + token, + auth, +}; +use crate::utils::Bool; + +#[async_trait::async_trait] +trait Interface { + fn client(&self) -> &reqwest::Client; + fn url(&self, endpoint: &str) -> Result; + fn current_token(&self) -> Option>; + async fn refresh_token(&self, api: Api) -> Result>, error::Token>; +} + +#[derive(Debug)] +struct Internal { + client: reqwest::Client, + base: reqwest::Url, + token_provider: T, +} + +impl Internal { + fn new(client: reqwest::Client, base: reqwest::Url, token_provider: T) + -> std::sync::Arc { + std::sync::Arc::new(Self { client, base, token_provider }) + } + + #[tracing::instrument(skip_all, fields(endpoint=request.endpoint(), request, token))] + async fn call(&self, request: &R, token: Option<&token::Token>) -> Result + { + let url = self.base.join(request.endpoint()).map_err(error::Api::Url)?; + let builder = self.client.request(R::METHOD, url); + let builder = if let Some(token) = token { + token.r#use(builder) + } else { + builder + }; + + let response = builder.json(request) + .send() + .await + .map_err(error::Api::Reqwest)?; + + match response.status() { + reqwest::StatusCode::OK => (), + status => return Err(error::Api::Http(status)), + } + let result: R::Response = response.json().await?; + Ok(result) + } +} + +async fn deserialize(response: reqwest::Response) -> Result +{ + let response: R::Response = response.json().await.map_err(error::Api::Reqwest)?; + Ok(response) +} + +#[tracing::instrument(skip_all, fields(url, request, token))] +async fn call(client: &reqwest::Client, url: reqwest::Url, request: &R, token: Option<&token::Token>) -> Result { + let builder = client.request(R::METHOD, url); + let builder = if let Some(token) = token { + builder.bearer_auth(token.as_ref()) + } else { + builder + }; + let response = builder.json(request) + .send() + .await + .map_err(error::Api::Reqwest)?; + + match response.status() { + reqwest::StatusCode::OK => + deserialize::(response).await, + status => Err(error::Api::Http(status)), + } +} + +#[async_trait::async_trait] +impl Interface for Internal { + fn client(&self) -> &reqwest::Client { + &self.client + } + + fn url(&self, endpoint: &str) -> Result { + self.base.join(endpoint) + } + + fn current_token(&self) -> Option> { + self.token_provider.current() + } + + async fn refresh_token(&self, api: Api) -> Result>, error::Token> { + self.token_provider.refresh(api).await + } +} + +#[derive(Debug)] +struct NoToken; + +#[async_trait::async_trait] +impl token::Provider for NoToken { + fn current(&self) -> Option> { + None + } + + async fn refresh(&self, _api: Api) -> Result>, error::Token> { + Ok(None) + } +} + +#[derive(Clone)] +pub struct Api(std::sync::Arc); + +impl Api { + pub async fn new(auth: A) -> Result + { + Self::new_with_base("https://api.spond.com", auth).await + } + + pub async fn new_with_base(base: &str, auth: A) -> Result { + let base = reqwest::Url::parse(base)?; + let host = base.host_str().unwrap().to_owned(); + + let client = reqwest::Client::builder() + //.https_only(true) + .redirect(reqwest::redirect::Policy::limited(1)) + .retry(reqwest::retry::for_host(host) + .max_retries_per_request(2) + .classify_fn(|req_rep| { + use reqwest::StatusCode; + match req_rep.status() { + Some(StatusCode::UNAUTHORIZED) => req_rep.retryable(), + _ => req_rep.success(), + } + })) + // TODO + //.cookie_store(true) + .user_agent("spond-selection-bot") + .read_timeout(std::time::Duration::from_secs(5)) + .connect_timeout(std::time::Duration::from_secs(15)) + .connection_verbose(true) + .build()?; + + let api = Api(Internal::new(client.clone(), base.clone(), NoToken)); + let provider = auth.authenticate(api).await?; + + tracing::info!("{:?}", provider); + let api = Api(Internal::new(client, base, provider)); + Ok(api) + } + + + pub async fn call(&self, request: &R) -> Result + { + //async fn call(&self, api: &Api, call: &C, request: &C::Request) -> Result> { + // let mut token = self.token_provider.current(); + // loop { + // match self.common.call(call, request, &token) { + // Err(error::Call::::Http(reqwest::StatusCode::UNAUTHORIZED)) if token.is_some_and(|token|token.expired()) + // => token = self.token_provider.refresh(api).map_err(error::Call::::Token)?, + // result => return result, + // } + // } + //} + + let client = self.0.client(); + + if R::Authorization::VALUE == false { + let url = self.0.url(request.endpoint())?; + call(client, url, request, None).await + } else { + let mut current = self.0.current_token(); + loop { + use std::ops::Deref; + let token = if let Some(ref token) = current { + Some(token.deref()) + } else { + None + }; + let url = self.0.url(request.endpoint())?; + current = match call(client, url, request, token).await { + Err(error::Api::Http(reqwest::StatusCode::UNAUTHORIZED)) if current.is_some_and(|t|t.expired()) + => self.0.refresh_token(self.clone()).await?, + result => break result, + } + } + } + } +} + +#[cfg(test)] +mod test { + use super::*; + + #[tokio::test] + async fn mock() {} +} + diff --git a/turnerbund/src/api/auth.rs b/turnerbund/src/api/auth.rs new file mode 100644 index 0000000..ddb54de --- /dev/null +++ b/turnerbund/src/api/auth.rs @@ -0,0 +1,185 @@ +use async_trait::async_trait; +use thiserror::Error; +use crate::utils::False; + +use super::{ + Request, + error, +}; + +use serde::{ + Deserialize, + Serialize, + Serializer, + ser::SerializeStruct, +}; + +#[derive(Debug, Error)] +pub enum Error { + //#[error(transparent)] + //Provider(P) + #[error("invalid credentials")] + Credentials, +} + +#[async_trait] +pub trait Provider { + type TokenProvider: super::token::Provider + 'static; + + async fn authenticate(&self, api: super::Api) -> Result; +} + +pub trait Identifier: Sync + Send + Serialize + std::fmt::Debug { + const KEY: &'static str; +} + +macro_rules! transparent_identifier { + ($name:ident, $key:expr) => { + transparent_string!($name); + + impl Identifier for $name { + const KEY: &'static str = $key; + } + }; +} + +macro_rules! transparent_string { + ($name:ident) => { + #[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize)] + #[serde(transparent)] + pub struct $name(String); + + impl From<&str> for $name { + fn from(s: &str) -> Self { + s.to_string().into() + } + } + + impl From for $name { + fn from(s: String) -> Self { + Self(s) + } + } + + impl<'a> From<&'a $name> for &'a str { + fn from(id: &'a $name) -> Self { + &id.0 + } + } + + impl From<$name> for String { + fn from(id: $name) -> Self { + id.0 + } + } + }; +} + +transparent_string!(Password); +transparent_identifier!(Email, "email"); +transparent_identifier!(Phone, "phone"); + +#[derive(Debug)] +pub struct Login { + identifier: I, + password: Password, +} + +impl Login { + pub fn new>(identifier: I, password: P) -> Self { + Self { + identifier: identifier, + password: password.into(), + } + } +} + +impl Serialize for Login { + fn serialize(&self, serializer: S) -> Result { + let mut state = serializer.serialize_struct("Login", 2)?; + state.serialize_field(I::KEY, &self.identifier)?; + state.serialize_field("password", &self.password)?; + state.end() + } +} + +#[async_trait] +impl Provider for Login { + type TokenProvider = TokenProvider; + + async fn authenticate(&self, api: super::Api) -> Result { + Ok(api.call(self).await?.into()) + //todo!("implement me") + } +} + +#[derive(Debug, Deserialize)] +#[serde(rename_all = "camelCase")] +pub struct Tokens { + access_token: super::token::Token, + refresh_token: super::token::Token, +} + +#[derive(Debug)] +pub struct TokenProvider { + access: std::sync::RwLock>, + refresh: std::sync::Mutex, +} + +impl From for TokenProvider { + fn from(tokens: Tokens) -> Self { + use std::sync::{Mutex,RwLock, Arc}; + Self { + access: RwLock::new(Arc::new(tokens.access_token)), + refresh: Mutex::new(tokens.refresh_token), + } + } +} + +#[async_trait::async_trait] +impl super::token::Provider for TokenProvider { + fn current(&self) -> Option> { + Some(self.access.read().ok()?.clone()) + } + + async fn refresh(&self, api: super::Api) -> Result>, super::error::Token> { + // TODO + let _ = api; + Err(super::error::Token::Expired(chrono::TimeDelta::seconds(-5))) + } +} + +impl Request for Login { + const METHOD: super::reqwest::Method = super::reqwest::Method::POST; + type Response = Tokens; + type Authorization = False; + + fn endpoint(&self) -> &str { + "core/v1/auth2/login" + } +} + + +#[cfg(test)] +mod test { + mod serialize { + use super::super::*; + use serde_json; + + #[test] + fn email_login() { + let login = Login::::new("user@spond.com", "secret"); + + let json = serde_json::to_string(&login).unwrap(); + assert_eq!(json, r#"{"email":"user@spond.com","password":"secret"}"#) + } + + #[test] + fn phone_login() { + let login = Login::::new("+1234567890", "secret"); + + let json = serde_json::to_string(&login).unwrap(); + assert_eq!(json, r#"{"phone":"+1234567890","password":"secret"}"#) + } + } +} diff --git a/turnerbund/src/api/endpoint/mod.rs b/turnerbund/src/api/endpoint/mod.rs new file mode 100644 index 0000000..a3dd347 --- /dev/null +++ b/turnerbund/src/api/endpoint/mod.rs @@ -0,0 +1,24 @@ +use serde::{Serialize, Deserialize}; + +pub trait Method { + const HTTP: http::Method; +} + +macro_rules! method { + ($name:ident) => { + struct $name; + + impl Method for $name { + const HTTP = http::Method::$name; + } + }; +} + +method!(GET); +method!(POST); + +pub trait Endpoint: Serialize { + type Result: Deserialize; + + fn path(&self) -> &str; +} diff --git a/turnerbund/src/api/error.rs b/turnerbund/src/api/error.rs new file mode 100644 index 0000000..5120e1b --- /dev/null +++ b/turnerbund/src/api/error.rs @@ -0,0 +1,29 @@ +pub trait Error: std::error::Error + std::fmt::Debug + Send + Sync + 'static {} +impl Error for E {} + +#[derive(Debug, thiserror::Error)] +pub enum Api { + #[error("reqwest")] + Reqwest(#[from] reqwest::Error), + + #[error("encode")] + Encode(serde_json::Error), + + #[error("decode")] + Decode(serde_json::Error), + + #[error("url")] + Url(#[from] url::ParseError), + + #[error("token")] + Token(#[from] Token), + + #[error("http")] + Http(reqwest::StatusCode), +} + +#[derive(Debug, thiserror::Error)] +pub enum Token { + #[error("expired token")] + Expired(chrono::TimeDelta), +} diff --git a/turnerbund/src/api/mod.rs b/turnerbund/src/api/mod.rs new file mode 100644 index 0000000..ce4563a --- /dev/null +++ b/turnerbund/src/api/mod.rs @@ -0,0 +1,32 @@ +pub mod auth; +pub mod token; +pub mod error; +pub mod request; +mod api; +pub use api::Api; +pub use request::{ + Request, +}; + +use reqwest_middleware::reqwest; + +#[derive(Debug, thiserror::Error)] +pub enum Error { + #[error("unspecified")] + Unspecified, + + #[error("reqwest error")] + Reqwest(#[from] reqwest::Error), + + #[error("middleware error")] + Middleware(anyhow::Error), + + #[error("url parser error")] + UrlParseError(#[from] url::ParseError), + + #[error("http status code")] + Http(reqwest::StatusCode), + + #[error(transparent)] + Custom(Auth) +} diff --git a/turnerbund/src/api/request.rs b/turnerbund/src/api/request.rs new file mode 100644 index 0000000..b9d880e --- /dev/null +++ b/turnerbund/src/api/request.rs @@ -0,0 +1,13 @@ +use crate::utils::Bool; + +trait Authorization: Bool {} + +impl Authorization for T {} + +pub trait Request: Sized + std::fmt::Debug + serde::Serialize { + const METHOD: reqwest::Method = reqwest::Method::GET; + type Authorization: Authorization; + type Response: for<'a> serde::Deserialize<'a> + Sized; + + fn endpoint(&self) -> &str; +} diff --git a/turnerbund/src/api/token.rs b/turnerbund/src/api/token.rs new file mode 100644 index 0000000..73965fb --- /dev/null +++ b/turnerbund/src/api/token.rs @@ -0,0 +1,38 @@ +use async_trait::async_trait; + +#[derive(Debug, Clone, serde::Deserialize)] +pub struct Token { + token: String, + expiration: chrono::DateTime, +} + +impl AsRef for Token { + fn as_ref(&self) -> &str { + &self.token + } +} + +impl Token { + pub fn expired(&self) -> bool { + self.expiration < chrono::Utc::now() + } + + pub fn expired_in(&self, offset: chrono::TimeDelta) -> bool { + self.time_delta() < offset + } + + pub fn time_delta(&self) -> chrono::TimeDelta { + self.expiration - chrono::Utc::now() + } + + pub fn r#use(&self, builder: reqwest::RequestBuilder) -> reqwest::RequestBuilder { + builder.bearer_auth(&self.token) + } +} + +#[async_trait] +pub trait Provider: std::fmt::Debug + Send + Sync { + fn current(&self) -> Option>; + + async fn refresh(&self, api: super::Api) -> Result>, super::error::Token>; +} diff --git a/turnerbund/src/client/mod.rs b/turnerbund/src/client/mod.rs new file mode 100644 index 0000000..83f0aad --- /dev/null +++ b/turnerbund/src/client/mod.rs @@ -0,0 +1,10 @@ +use reqwest_middleware::reqwest; +use reqwest_middleware::ClientWithMiddleware as Backend; + +struct Client { + backend: Backend, +} + +impl Client { + +} diff --git a/turnerbund/src/id.rs b/turnerbund/src/id.rs new file mode 100644 index 0000000..e628b3e --- /dev/null +++ b/turnerbund/src/id.rs @@ -0,0 +1,74 @@ +use serde::{Serialize, Deserialize, Serializer, Deserializer}; +use serde::de; +use std::fmt; +use std::str::FromStr; +use super::api::Api; + +#[derive(Debug)] +pub enum ParseError { + Length(usize), + IntError(std::num::ParseIntError), +} + +impl From for ParseError { + fn from(e: std::num::ParseIntError) -> Self { + Self::IntError(e) + } +} + +impl fmt::Display for ParseError { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + match self { + Self::Length(len) => write!(f, "Id strig must be 32 characters, got {}", len), + Self::IntError(e) => write!(f, "{}", e), + } + } +} + +pub trait Marker { + async fn resolve(id: Id, api: Api) -> Result; +} + +#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] +pub struct Id(u128, std::marker::PhantomData); + +impl Id { + pub fn new(value: u128) -> Self { + Self(value, std::marker::PhantomData) + } + + pub fn value(&self) -> u128 { + self.0 + } +} + +impl fmt::Display for Id { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + write!(f, "{:032X}", self.0) + } +} + +impl FromStr for Id { + type Err = ParseError; + + fn from_str(s: &str) -> Result { + match s.len() { + 32 => Ok(Self::new(u128::from_str_radix(s, 16)?)), + len => Err(ParseError::Length(len)), + } + } +} + +impl Serialize for Id { + fn serialize(&self, serializer: S) -> Result { + serializer.serialize_str(&self.to_string()) + } +} + +impl<'de, T: Marker> Deserialize<'de> for Id { + fn deserialize>(deserializer: D) -> Result { + String::deserialize(deserializer)? + .parse() + .map_err(de::Error::custom) + } +} diff --git a/turnerbund/src/main.rs b/turnerbund/src/main.rs new file mode 100644 index 0000000..fe9b31d --- /dev/null +++ b/turnerbund/src/main.rs @@ -0,0 +1,51 @@ +use tracing_subscriber::prelude::*; +use tracing_subscriber::{fmt, EnvFilter}; +pub use tracing::{error, warn, info, debug, trace}; + +fn tracing_setup(filter: &str) { + let filter = EnvFilter::try_from_default_env() + .unwrap_or_else(|_| EnvFilter::new(filter)); + + tracing_subscriber::registry() + .with(fmt::layer().pretty()) + .with(filter) + .init(); +} + +async fn connect(authenticator: A, credentials: C) -> Result::Error, >::Error>> { + let auth = spond::authentication::Login; + + authenticator.authenticate(&auth, &credentials).await +} + +#[tokio::main] +async fn main() -> anyhow::Result<()> { + tracing_setup("info"); + + #[cfg(feature="disabled")] + disabled::main().await; + + error!("Error Message"); + warn!("Warn Message"); + info!("Info Message"); + debug!("Debug Message"); + trace!("Trace Message"); + + let pw = std::env::var("SPOND_PASSWORD").expect("a password is required in SPOND_PASSWORD"); + let client = spond::reqwest::Public::new().expect("public client"); + let client = if let Ok(email) = std::env::var("SPOND_EMAIL") { + connect(client, spond::authentication::login::Email::new(&email, &pw)).await + } else if let Ok(phone) = std::env::var("SPOND_PHONE") { + connect(client, spond::authentication::login::Phone::new(&phone, &pw)).await + } else { + panic!("no credentials provided"); + }?; + + + use spond::traits::client::Private; + + let _ = client.execute(&spond::schema::sponds::Sponds::default(), &spond::schema::sponds::Upcoming).await?; + + + Ok(()) +} diff --git a/turnerbund/src/select.rs b/turnerbund/src/select.rs new file mode 100644 index 0000000..ef0abcc --- /dev/null +++ b/turnerbund/src/select.rs @@ -0,0 +1,166 @@ +use rand::prelude::*; +use std::collections::HashSet; +use std::collections::HashMap; + +#[derive(Debug, Clone, Copy, Eq, Hash, PartialEq, PartialOrd, Ord)] +struct UserID(u128); + +impl std::fmt::Display for UserID { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + write!(f, "UserID({})", self.0) + } +} + +#[derive(Default)] +struct Participants(Vec<(UserID, usize)>); + +trait Event { + fn registered(&self, uid: UserID) -> bool; + fn participated(&self, uid: UserID) -> bool { self.registered(uid) } +} + +impl Participants { + pub fn add(mut self, uid: UserID) -> Self { + self.0.push((uid, 1)); + self + } + + pub fn select(mut self, history: IntoIterator, rng: &mut impl Rng, count: usize) + -> HashSet + { + for event in history { + let mut modified = false; + for item in self.0.iter_mut() { + if event.registered(item.0) && !event.participated(item.0) { + modified = true; + item.1 += 1; + } + } + if !modified { + break; + } + } + + println!("{:?}", self.0); + + self.0.sample_weighted(rng, count, |item: &'_ (_, usize)| item.1 as f64) + .unwrap() + .map(|item| item.0) + .collect() + } +} + +#[cfg(feature="disabled")] +mod disabled { + +//mod select; +//use select::WeightedSet; + +use tracing_subscriber::prelude::*; +use tracing_subscriber::{fmt, EnvFilter}; +pub use tracing::{error, warn, info, debug, trace}; + + +#[derive(Debug, thiserror::Error)] +pub enum NoError {} + + + +#[derive(Clone)] +struct MockEvent { + id: usize, + users: HashMap, +} + +impl MockEvent { + fn new(id: usize, registrants: HashSet, participants: HashSet) -> Self { + let users = registrants.into_iter() + .map(|uid| (uid, participants.contains(&uid))) + .collect(); + Self { id, users } + } +} + +impl std::fmt::Display for MockEvent { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + write!(f, "MockEvent{}({:?})", self.id, self.users) + } +} + +impl Event for &MockEvent { + fn registered(&self, uid: UserID) -> bool { + self.users.get(&uid).is_some() + } + + fn participated(&self, uid: UserID) -> bool { + self.users.get(&uid).is_some_and(|participated|*participated) + } +} + +async fn connect<'a, I: spond::auth::Identifier + From<&'a str>>(id: &'a str) -> Result { + let pw = std::env::var("SPOND_PASSWORD").expect("a password is required in SPOND_PASSWORD"); + let id: I = id.into(); + let auth = spond::auth::Login::new(id, pw); + let client = spond::Api::new(auth).await?; + Ok(client) +} + +async fn main() -> anyhow::Result<()> { + let filter = EnvFilter::try_from_default_env() + .unwrap_or_else(|_| EnvFilter::new("info")); + tracing_subscriber::registry() + .with(fmt::layer().pretty()) + .with(filter) + .init(); + + error!("Error Message"); + warn!("Warn Message"); + info!("Info Message"); + debug!("Debug Message"); + trace!("Trace Message"); + + let client = if let Ok(email) = std::env::var("SPOND_EMAIL") { + connect::(&email).await? + } else if let Ok(phone) = std::env::var("SPOND_PHONE") { + connect::(&phone).await? + } else { + panic!("no credentials provided"); + }; + + let _ = client; + + + let users = (0..25).map(UserID).collect::>(); + let mut events = Vec::new(); + + for id in 0..5 { + let mut rng = rand::rng(); + let want = users.iter().filter(|_| (&mut rng).random_bool(0.75)).map(|id|id.clone()).collect::>(); + + let mut participants = Participants::default(); + for uid in want.iter() { + participants = participants.add(*uid); + } + + let participants = participants.select(events.iter().rev(), &mut rng, 12); + let event = MockEvent::new(id, want, participants); + println!("{event}"); + events.push(event); + } + + for uid in users.into_iter() { + let (registered, participated) = events.iter() + .fold((0, 0), |(registered, participated), event| { + let registered = registered + if event.registered(uid) { 1 } else { 0 }; + let participated = participated + if event.participated(uid) { 1 } else { 0 }; + (registered, participated) + }); + + println!("{uid}: ({participated}/{registered}) {:.2}%", + (participated as f64) / (registered as f64) * 100f64); + } + + Ok(()) +} +} + diff --git a/turnerbund/src/select/candidate.rs b/turnerbund/src/select/candidate.rs new file mode 100644 index 0000000..ac1a094 --- /dev/null +++ b/turnerbund/src/select/candidate.rs @@ -0,0 +1,48 @@ +use super::Key; +use std::cmp::Ordering; + +#[derive(Debug)] +pub struct Candidate { + item: T, + key: Key, +} + +impl Candidate { + pub fn new_with_key(item: T, key: Key) -> Self { + Self { item, key } + } + + pub fn new(item: T, rng: R, weight: W) -> Option + where + R: FnOnce() -> F, + F: Into, + W: Into, + { + Key::new(rng, weight).map(|key|Self::new_with_key(item, key)) + } + + pub fn item(self) -> T { + self.item + } +} + +impl Ord for Candidate { + fn cmp(&self, other: &Self) -> Ordering { + // Reverse for max-heap: largest key is "greatest" + other.key.partial_cmp(&self.key).unwrap().reverse() + } +} + +impl PartialOrd for Candidate { + fn partial_cmp(&self, other: &Self) -> Option { + Some(self.cmp(other)) + } +} + +impl PartialEq for Candidate { + fn eq(&self, other: &Self) -> bool { + self.key == other.key + } +} + +impl Eq for Candidate {} diff --git a/turnerbund/src/select/key.rs b/turnerbund/src/select/key.rs new file mode 100644 index 0000000..e75b5fa --- /dev/null +++ b/turnerbund/src/select/key.rs @@ -0,0 +1,31 @@ +// Key newtype wrapping a f64 in the range [0.0,1.0] +#[derive(Debug, Clone, Copy, PartialEq, PartialOrd)] +pub struct Key(f64); + +impl Key { + pub fn new(rng: R, weight: W) -> Option + where + R: FnOnce() -> F, + F: Into, + W: Into, + { + let weight = weight.into(); + + if weight.is_finite() && weight > 0.0 { + let u = -rng().into().ln(); + Some(Key((u / weight).recip())) + } else { + None + } + } +} + +impl Ord for Key { + fn cmp(&self, other: &Self) -> std::cmp::Ordering { + // we are always in range [0.0,1.0] + self.0.partial_cmp(&other.0).unwrap() + } +} + +impl Eq for Key {} + diff --git a/turnerbund/src/user.rs b/turnerbund/src/user.rs new file mode 100644 index 0000000..f75071f --- /dev/null +++ b/turnerbund/src/user.rs @@ -0,0 +1,2 @@ +struct Profile; +struct User; diff --git a/turnerbund/src/utils.rs b/turnerbund/src/utils.rs new file mode 100644 index 0000000..698dc9e --- /dev/null +++ b/turnerbund/src/utils.rs @@ -0,0 +1,19 @@ +trait BoolValue {} + +pub trait Bool: BoolValue { + const VALUE: bool; +} + +pub struct True; +pub struct False; + +impl BoolValue for True {} +impl BoolValue for False {} + +impl Bool for True { + const VALUE: bool = true; +} + +impl Bool for False { + const VALUE: bool = false; +} From a0d3c6cf9c0ed129c13f532549aa560295efc525 Mon Sep 17 00:00:00 2001 From: Jonas Rabenstein Date: Fri, 27 Feb 2026 03:28:09 +0100 Subject: [PATCH 02/15] restson --- cli/Cargo.lock | 1894 +++++++++++++++++++++++++++++++++++++ cli/Cargo.toml | 18 + cli/src/api/mod.rs | 78 ++ cli/src/authentication.rs | 165 ++++ cli/src/main.rs | 62 ++ cli/src/request/get.rs | 111 +++ cli/src/request/mod.rs | 2 + cli/src/request/post.rs | 85 ++ 8 files changed, 2415 insertions(+) create mode 100644 cli/Cargo.lock create mode 100644 cli/Cargo.toml create mode 100644 cli/src/api/mod.rs create mode 100644 cli/src/authentication.rs create mode 100644 cli/src/main.rs create mode 100644 cli/src/request/get.rs create mode 100644 cli/src/request/mod.rs create mode 100644 cli/src/request/post.rs diff --git a/cli/Cargo.lock b/cli/Cargo.lock new file mode 100644 index 0000000..0166b8b --- /dev/null +++ b/cli/Cargo.lock @@ -0,0 +1,1894 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +version = 4 + +[[package]] +name = "aho-corasick" +version = "1.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ddd31a130427c27518df266943a5308ed92d4b226cc639f5a8f1002816174301" +dependencies = [ + "memchr", +] + +[[package]] +name = "android_system_properties" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "819e7219dbd41043ac279b19830f2efc897156490d7fd6ea916720117ee66311" +dependencies = [ + "libc", +] + +[[package]] +name = "anstream" +version = "0.6.21" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "43d5b281e737544384e969a5ccad3f1cdd24b48086a0fc1b2a5262a26b8f4f4a" +dependencies = [ + "anstyle", + "anstyle-parse", + "anstyle-query", + "anstyle-wincon", + "colorchoice", + "is_terminal_polyfill", + "utf8parse", +] + +[[package]] +name = "anstyle" +version = "1.0.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5192cca8006f1fd4f7237516f40fa183bb07f8fbdfedaa0036de5ea9b0b45e78" + +[[package]] +name = "anstyle-parse" +version = "0.2.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4e7644824f0aa2c7b9384579234ef10eb7efb6a0deb83f9630a49594dd9c15c2" +dependencies = [ + "utf8parse", +] + +[[package]] +name = "anstyle-query" +version = "1.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "40c48f72fd53cd289104fc64099abca73db4166ad86ea0b4341abe65af83dadc" +dependencies = [ + "windows-sys 0.61.2", +] + +[[package]] +name = "anstyle-wincon" +version = "3.0.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "291e6a250ff86cd4a820112fb8898808a366d8f9f58ce16d1f538353ad55747d" +dependencies = [ + "anstyle", + "once_cell_polyfill", + "windows-sys 0.61.2", +] + +[[package]] +name = "anyhow" +version = "1.0.102" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7f202df86484c868dbad7eaa557ef785d5c66295e41b460ef922eca0723b842c" + +[[package]] +name = "autocfg" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c08606f8c3cbf4ce6ec8e28fb0014a2c086708fe954eaa885384a6165172e7e8" + +[[package]] +name = "base64" +version = "0.13.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9e1b586273c5702936fe7b7d6896644d8be71e6314cfe09d3167c95f712589e8" + +[[package]] +name = "bitflags" +version = "2.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "843867be96c8daad0d758b57df9392b6d8d271134fce549de6ce169ff98a92af" + +[[package]] +name = "bon" +version = "3.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2d13a61f2963b88eef9c1be03df65d42f6996dfeac1054870d950fcf66686f83" +dependencies = [ + "bon-macros", + "rustversion", +] + +[[package]] +name = "bon-macros" +version = "3.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d314cc62af2b6b0c65780555abb4d02a03dd3b799cd42419044f0c38d99738c0" +dependencies = [ + "darling", + "ident_case", + "prettyplease", + "proc-macro2", + "quote", + "rustversion", + "syn", +] + +[[package]] +name = "bumpalo" +version = "3.20.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5d20789868f4b01b2f2caec9f5c4e0213b41e3e5702a50157d699ae31ced2fcb" + +[[package]] +name = "bytes" +version = "1.11.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1e748733b7cbc798e1434b6ac524f0c1ff2ab456fe201501e6497c8417a4fc33" + +[[package]] +name = "cc" +version = "1.2.56" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "aebf35691d1bfb0ac386a69bac2fde4dd276fb618cf8bf4f5318fe285e821bb2" +dependencies = [ + "find-msvc-tools", + "shlex", +] + +[[package]] +name = "cfg-if" +version = "1.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9330f8b2ff13f34540b44e946ef35111825727b38d33286ef986142615121801" + +[[package]] +name = "chrono" +version = "0.4.44" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c673075a2e0e5f4a1dde27ce9dee1ea4558c7ffe648f576438a20ca1d2acc4b0" +dependencies = [ + "iana-time-zone", + "js-sys", + "num-traits", + "serde", + "wasm-bindgen", + "windows-link", +] + +[[package]] +name = "clap" +version = "4.5.60" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2797f34da339ce31042b27d23607e051786132987f595b02ba4f6a6dffb7030a" +dependencies = [ + "clap_builder", + "clap_derive", +] + +[[package]] +name = "clap_builder" +version = "4.5.60" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "24a241312cea5059b13574bb9b3861cabf758b879c15190b37b6d6fd63ab6876" +dependencies = [ + "anstream", + "anstyle", + "clap_lex", + "strsim", +] + +[[package]] +name = "clap_derive" +version = "4.5.55" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a92793da1a46a5f2a02a6f4c46c6496b28c43638adea8306fcb0caa1634f24e5" +dependencies = [ + "heck", + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "clap_lex" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3a822ea5bc7590f9d40f1ba12c0dc3c2760f3482c6984db1573ad11031420831" + +[[package]] +name = "colorchoice" +version = "1.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b05b61dc5112cbb17e4b6cd61790d9845d13888356391624cbe7e41efeac1e75" + +[[package]] +name = "core-foundation" +version = "0.10.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b2a6cd9ae233e7f62ba4e9353e81a88df7fc8a5987b8d445b4d90c879bd156f6" +dependencies = [ + "core-foundation-sys", + "libc", +] + +[[package]] +name = "core-foundation-sys" +version = "0.8.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "773648b94d0e5d620f64f280777445740e61fe701025087ec8b57f45c791888b" + +[[package]] +name = "darling" +version = "0.23.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "25ae13da2f202d56bd7f91c25fba009e7717a1e4a1cc98a76d844b65ae912e9d" +dependencies = [ + "darling_core", + "darling_macro", +] + +[[package]] +name = "darling_core" +version = "0.23.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9865a50f7c335f53564bb694ef660825eb8610e0a53d3e11bf1b0d3df31e03b0" +dependencies = [ + "ident_case", + "proc-macro2", + "quote", + "strsim", + "syn", +] + +[[package]] +name = "darling_macro" +version = "0.23.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ac3984ec7bd6cfa798e62b4a642426a5be0e68f9401cfc2a01e3fa9ea2fcdb8d" +dependencies = [ + "darling_core", + "quote", + "syn", +] + +[[package]] +name = "displaydoc" +version = "0.2.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "97369cbbc041bc366949bc74d34658d6cda5621039731c6310521892a3a20ae0" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "env_filter" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7a1c3cc8e57274ec99de65301228b537f1e4eedc1b8e0f9411c6caac8ae7308f" +dependencies = [ + "log", + "regex", +] + +[[package]] +name = "env_logger" +version = "0.11.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b2daee4ea451f429a58296525ddf28b45a3b64f1acf6587e2067437bb11e218d" +dependencies = [ + "anstream", + "anstyle", + "env_filter", + "jiff", + "log", +] + +[[package]] +name = "equivalent" +version = "1.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "877a4ace8713b0bcf2a4e7eec82529c029f1d0619886d18145fea96c3ffe5c0f" + +[[package]] +name = "errno" +version = "0.3.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "39cab71617ae0d63f51a36d69f866391735b51691dbda63cf6f96d042b63efeb" +dependencies = [ + "libc", + "windows-sys 0.61.2", +] + +[[package]] +name = "fastrand" +version = "2.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "37909eebbb50d72f9059c3b6d82c0463f2ff062c9e95845c43a6c9c0355411be" + +[[package]] +name = "find-msvc-tools" +version = "0.1.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5baebc0774151f905a1a2cc41989300b1e6fbb29aff0ceffa1064fdd3088d582" + +[[package]] +name = "fnv" +version = "1.0.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1" + +[[package]] +name = "foldhash" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d9c4f5dac5e15c24eb999c26181a6ca40b39fe946cbe4c263c7209467bc83af2" + +[[package]] +name = "foreign-types" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f6f339eb8adc052cd2ca78910fda869aefa38d22d5cb648e6485e4d3fc06f3b1" +dependencies = [ + "foreign-types-shared", +] + +[[package]] +name = "foreign-types-shared" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "00b0228411908ca8685dba7fc2cdd70ec9990a6e753e89b6ac91a84c40fbaf4b" + +[[package]] +name = "form_urlencoded" +version = "1.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cb4cb245038516f5f85277875cdaa4f7d2c9a0fa0468de06ed190163b1581fcf" +dependencies = [ + "percent-encoding", +] + +[[package]] +name = "futures" +version = "0.3.32" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8b147ee9d1f6d097cef9ce628cd2ee62288d963e16fb287bd9286455b241382d" +dependencies = [ + "futures-channel", + "futures-core", + "futures-executor", + "futures-io", + "futures-sink", + "futures-task", + "futures-util", +] + +[[package]] +name = "futures-channel" +version = "0.3.32" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "07bbe89c50d7a535e539b8c17bc0b49bdb77747034daa8087407d655f3f7cc1d" +dependencies = [ + "futures-core", + "futures-sink", +] + +[[package]] +name = "futures-core" +version = "0.3.32" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7e3450815272ef58cec6d564423f6e755e25379b217b0bc688e295ba24df6b1d" + +[[package]] +name = "futures-executor" +version = "0.3.32" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "baf29c38818342a3b26b5b923639e7b1f4a61fc5e76102d4b1981c6dc7a7579d" +dependencies = [ + "futures-core", + "futures-task", + "futures-util", +] + +[[package]] +name = "futures-io" +version = "0.3.32" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cecba35d7ad927e23624b22ad55235f2239cfa44fd10428eecbeba6d6a717718" + +[[package]] +name = "futures-macro" +version = "0.3.32" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e835b70203e41293343137df5c0664546da5745f82ec9b84d40be8336958447b" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "futures-sink" +version = "0.3.32" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c39754e157331b013978ec91992bde1ac089843443c49cbc7f46150b0fad0893" + +[[package]] +name = "futures-task" +version = "0.3.32" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "037711b3d59c33004d3856fbdc83b99d4ff37a24768fa1be9ce3538a1cde4393" + +[[package]] +name = "futures-util" +version = "0.3.32" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "389ca41296e6190b48053de0321d02a77f32f8a5d2461dd38762c0593805c6d6" +dependencies = [ + "futures-channel", + "futures-core", + "futures-io", + "futures-macro", + "futures-sink", + "futures-task", + "memchr", + "pin-project-lite", + "slab", +] + +[[package]] +name = "getrandom" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "139ef39800118c7683f2fd3c98c1b23c09ae076556b435f8e9064ae108aaeeec" +dependencies = [ + "cfg-if", + "libc", + "r-efi", + "wasip2", + "wasip3", +] + +[[package]] +name = "h2" +version = "0.3.27" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0beca50380b1fc32983fc1cb4587bfa4bb9e78fc259aad4a0032d2080309222d" +dependencies = [ + "bytes", + "fnv", + "futures-core", + "futures-sink", + "futures-util", + "http 0.2.12", + "indexmap", + "slab", + "tokio", + "tokio-util", + "tracing", +] + +[[package]] +name = "hashbrown" +version = "0.15.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9229cfe53dfd69f0609a49f65461bd93001ea1ef889cd5529dd176593f5338a1" +dependencies = [ + "foldhash", +] + +[[package]] +name = "hashbrown" +version = "0.16.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "841d1cc9bed7f9236f321df977030373f4a4163ae1a7dbfe1a51a2c1a51d9100" + +[[package]] +name = "heck" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2304e00983f87ffb38b55b444b5e3b60a884b5d30c0fca7d82fe33449bbe55ea" + +[[package]] +name = "http" +version = "0.2.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "601cbb57e577e2f5ef5be8e7b83f0f63994f25aa94d673e54a92d5c516d101f1" +dependencies = [ + "bytes", + "fnv", + "itoa", +] + +[[package]] +name = "http" +version = "1.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e3ba2a386d7f85a81f119ad7498ebe444d2e22c2af0b86b069416ace48b3311a" +dependencies = [ + "bytes", + "itoa", +] + +[[package]] +name = "http-body" +version = "0.4.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7ceab25649e9960c0311ea418d17bee82c0dcec1bd053b5f9a66e265a693bed2" +dependencies = [ + "bytes", + "http 0.2.12", + "pin-project-lite", +] + +[[package]] +name = "httparse" +version = "1.10.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6dbf3de79e51f3d586ab4cb9d5c3e2c14aa28ed23d180cf89b4df0454a69cc87" + +[[package]] +name = "httpdate" +version = "1.0.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "df3b46402a9d5adb4c86a0cf463f42e19994e3ee891101b1841f30a545cb49a9" + +[[package]] +name = "hyper" +version = "0.14.32" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "41dfc780fdec9373c01bae43289ea34c972e40ee3c9f6b3c8801a35f35586ce7" +dependencies = [ + "bytes", + "futures-channel", + "futures-core", + "futures-util", + "h2", + "http 0.2.12", + "http-body", + "httparse", + "httpdate", + "itoa", + "pin-project-lite", + "socket2 0.5.10", + "tokio", + "tower-service", + "tracing", + "want", +] + +[[package]] +name = "hyper-tls" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d6183ddfa99b85da61a140bea0efc93fdf56ceaa041b37d553518030827f9905" +dependencies = [ + "bytes", + "hyper", + "native-tls", + "tokio", + "tokio-native-tls", +] + +[[package]] +name = "iana-time-zone" +version = "0.1.65" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e31bc9ad994ba00e440a8aa5c9ef0ec67d5cb5e5cb0cc7f8b744a35b389cc470" +dependencies = [ + "android_system_properties", + "core-foundation-sys", + "iana-time-zone-haiku", + "js-sys", + "log", + "wasm-bindgen", + "windows-core", +] + +[[package]] +name = "iana-time-zone-haiku" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f31827a206f56af32e590ba56d5d2d085f558508192593743f16b2306495269f" +dependencies = [ + "cc", +] + +[[package]] +name = "icu_collections" +version = "2.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4c6b649701667bbe825c3b7e6388cb521c23d88644678e83c0c4d0a621a34b43" +dependencies = [ + "displaydoc", + "potential_utf", + "yoke", + "zerofrom", + "zerovec", +] + +[[package]] +name = "icu_locale_core" +version = "2.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "edba7861004dd3714265b4db54a3c390e880ab658fec5f7db895fae2046b5bb6" +dependencies = [ + "displaydoc", + "litemap", + "tinystr", + "writeable", + "zerovec", +] + +[[package]] +name = "icu_normalizer" +version = "2.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5f6c8828b67bf8908d82127b2054ea1b4427ff0230ee9141c54251934ab1b599" +dependencies = [ + "icu_collections", + "icu_normalizer_data", + "icu_properties", + "icu_provider", + "smallvec", + "zerovec", +] + +[[package]] +name = "icu_normalizer_data" +version = "2.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7aedcccd01fc5fe81e6b489c15b247b8b0690feb23304303a9e560f37efc560a" + +[[package]] +name = "icu_properties" +version = "2.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "020bfc02fe870ec3a66d93e677ccca0562506e5872c650f893269e08615d74ec" +dependencies = [ + "icu_collections", + "icu_locale_core", + "icu_properties_data", + "icu_provider", + "zerotrie", + "zerovec", +] + +[[package]] +name = "icu_properties_data" +version = "2.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "616c294cf8d725c6afcd8f55abc17c56464ef6211f9ed59cccffe534129c77af" + +[[package]] +name = "icu_provider" +version = "2.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "85962cf0ce02e1e0a629cc34e7ca3e373ce20dda4c4d7294bbd0bf1fdb59e614" +dependencies = [ + "displaydoc", + "icu_locale_core", + "writeable", + "yoke", + "zerofrom", + "zerotrie", + "zerovec", +] + +[[package]] +name = "id-arena" +version = "2.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3d3067d79b975e8844ca9eb072e16b31c3c1c36928edf9c6789548c524d0d954" + +[[package]] +name = "ident_case" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b9e0384b61958566e926dc50660321d12159025e767c18e043daf26b70104c39" + +[[package]] +name = "idna" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3b0875f23caa03898994f6ddc501886a45c7d3d62d04d2d90788d47be1b1e4de" +dependencies = [ + "idna_adapter", + "smallvec", + "utf8_iter", +] + +[[package]] +name = "idna_adapter" +version = "1.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3acae9609540aa318d1bc588455225fb2085b9ed0c4f6bd0d9d5bcd86f1a0344" +dependencies = [ + "icu_normalizer", + "icu_properties", +] + +[[package]] +name = "indexmap" +version = "2.13.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7714e70437a7dc3ac8eb7e6f8df75fd8eb422675fc7678aff7364301092b1017" +dependencies = [ + "equivalent", + "hashbrown 0.16.1", + "serde", + "serde_core", +] + +[[package]] +name = "is_terminal_polyfill" +version = "1.70.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a6cb138bb79a146c1bd460005623e142ef0181e3d0219cb493e02f7d08a35695" + +[[package]] +name = "itoa" +version = "1.0.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "92ecc6618181def0457392ccd0ee51198e065e016d1d527a7ac1b6dc7c1f09d2" + +[[package]] +name = "jiff" +version = "0.2.21" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b3e3d65f018c6ae946ab16e80944b97096ed73c35b221d1c478a6c81d8f57940" +dependencies = [ + "jiff-static", + "log", + "portable-atomic", + "portable-atomic-util", + "serde_core", +] + +[[package]] +name = "jiff-static" +version = "0.2.21" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a17c2b211d863c7fde02cbea8a3c1a439b98e109286554f2860bdded7ff83818" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "js-sys" +version = "0.3.90" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "14dc6f6450b3f6d4ed5b16327f38fed626d375a886159ca555bd7822c0c3a5a6" +dependencies = [ + "once_cell", + "wasm-bindgen", +] + +[[package]] +name = "leb128fmt" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "09edd9e8b54e49e587e4f6295a7d29c3ea94d469cb40ab8ca70b288248a81db2" + +[[package]] +name = "libc" +version = "0.2.182" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6800badb6cb2082ffd7b6a67e6125bb39f18782f793520caee8cb8846be06112" + +[[package]] +name = "linux-raw-sys" +version = "0.12.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "32a66949e030da00e8c7d4434b251670a91556f4144941d37452769c25d58a53" + +[[package]] +name = "litemap" +version = "0.8.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6373607a59f0be73a39b6fe456b8192fcc3585f602af20751600e974dd455e77" + +[[package]] +name = "log" +version = "0.4.29" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5e5032e24019045c762d3c0f28f5b6b8bbf38563a65908389bf7978758920897" + +[[package]] +name = "memchr" +version = "2.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f8ca58f447f06ed17d5fc4043ce1b10dd205e060fb3ce5b979b8ed8e59ff3f79" + +[[package]] +name = "mio" +version = "1.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a69bcab0ad47271a0234d9422b131806bf3968021e5dc9328caf2d4cd58557fc" +dependencies = [ + "libc", + "wasi", + "windows-sys 0.61.2", +] + +[[package]] +name = "native-tls" +version = "0.2.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "465500e14ea162429d264d44189adc38b199b62b1c21eea9f69e4b73cb03bbf2" +dependencies = [ + "libc", + "log", + "openssl", + "openssl-probe", + "openssl-sys", + "schannel", + "security-framework", + "security-framework-sys", + "tempfile", +] + +[[package]] +name = "num-traits" +version = "0.2.19" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "071dfc062690e90b734c0b2273ce72ad0ffa95f0c74596bc250dcfd960262841" +dependencies = [ + "autocfg", +] + +[[package]] +name = "once_cell" +version = "1.21.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "42f5e15c9953c5e4ccceeb2e7382a716482c34515315f7b03532b8b4e8393d2d" + +[[package]] +name = "once_cell_polyfill" +version = "1.70.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "384b8ab6d37215f3c5301a95a4accb5d64aa607f1fcb26a11b5303878451b4fe" + +[[package]] +name = "openssl" +version = "0.10.75" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "08838db121398ad17ab8531ce9de97b244589089e290a384c900cb9ff7434328" +dependencies = [ + "bitflags", + "cfg-if", + "foreign-types", + "libc", + "once_cell", + "openssl-macros", + "openssl-sys", +] + +[[package]] +name = "openssl-macros" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a948666b637a0f465e8564c73e89d4dde00d72d4d473cc972f390fc3dcee7d9c" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "openssl-probe" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7c87def4c32ab89d880effc9e097653c8da5d6ef28e6b539d313baaacfbafcbe" + +[[package]] +name = "openssl-sys" +version = "0.9.111" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "82cab2d520aa75e3c58898289429321eb788c3106963d0dc886ec7a5f4adc321" +dependencies = [ + "cc", + "libc", + "pkg-config", + "vcpkg", +] + +[[package]] +name = "percent-encoding" +version = "2.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9b4f627cb1b25917193a259e49bdad08f671f8d9708acfd5fe0a8c1455d87220" + +[[package]] +name = "pin-project-lite" +version = "0.2.16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3b3cff922bd51709b605d9ead9aa71031d81447142d828eb4a6eba76fe619f9b" + +[[package]] +name = "pkg-config" +version = "0.3.32" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7edddbd0b52d732b21ad9a5fab5c704c14cd949e5e9a1ec5929a24fded1b904c" + +[[package]] +name = "portable-atomic" +version = "1.13.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c33a9471896f1c69cecef8d20cbe2f7accd12527ce60845ff44c153bb2a21b49" + +[[package]] +name = "portable-atomic-util" +version = "0.2.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7a9db96d7fa8782dd8c15ce32ffe8680bbd1e978a43bf51a34d39483540495f5" +dependencies = [ + "portable-atomic", +] + +[[package]] +name = "potential_utf" +version = "0.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b73949432f5e2a09657003c25bca5e19a0e9c84f8058ca374f49e0ebe605af77" +dependencies = [ + "zerovec", +] + +[[package]] +name = "prettyplease" +version = "0.2.37" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "479ca8adacdd7ce8f1fb39ce9ecccbfe93a3f1344b3d0d97f20bc0196208f62b" +dependencies = [ + "proc-macro2", + "syn", +] + +[[package]] +name = "proc-macro2" +version = "1.0.106" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8fd00f0bb2e90d81d1044c2b32617f68fcb9fa3bb7640c23e9c748e53fb30934" +dependencies = [ + "unicode-ident", +] + +[[package]] +name = "quote" +version = "1.0.44" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "21b2ebcf727b7760c461f091f9f0f539b77b8e87f2fd88131e7f1b433b3cece4" +dependencies = [ + "proc-macro2", +] + +[[package]] +name = "r-efi" +version = "5.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "69cdb34c158ceb288df11e18b4bd39de994f6657d83847bdffdbd7f346754b0f" + +[[package]] +name = "regex" +version = "1.12.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e10754a14b9137dd7b1e3e5b0493cc9171fdd105e0ab477f51b72e7f3ac0e276" +dependencies = [ + "aho-corasick", + "memchr", + "regex-automata", + "regex-syntax", +] + +[[package]] +name = "regex-automata" +version = "0.4.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6e1dd4122fc1595e8162618945476892eefca7b88c52820e74af6262213cae8f" +dependencies = [ + "aho-corasick", + "memchr", + "regex-syntax", +] + +[[package]] +name = "regex-syntax" +version = "0.8.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dc897dd8d9e8bd1ed8cdad82b5966c3e0ecae09fb1907d58efaa013543185d0a" + +[[package]] +name = "restson" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c4e434e0167dbe869e2da4836921fcfbba4a3537716e110ea478350b25434c18" +dependencies = [ + "base64", + "futures", + "hyper", + "hyper-tls", + "log", + "serde", + "serde_json", + "tokio", + "url", +] + +[[package]] +name = "rpassword" +version = "7.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "66d4c8b64f049c6721ec8ccec37ddfc3d641c4a7fca57e8f2a89de509c73df39" +dependencies = [ + "libc", + "rtoolbox", + "windows-sys 0.59.0", +] + +[[package]] +name = "rtoolbox" +version = "0.0.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a7cc970b249fbe527d6e02e0a227762c9108b2f49d81094fe357ffc6d14d7f6f" +dependencies = [ + "libc", + "windows-sys 0.52.0", +] + +[[package]] +name = "rustix" +version = "1.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b6fe4565b9518b83ef4f91bb47ce29620ca828bd32cb7e408f0062e9930ba190" +dependencies = [ + "bitflags", + "errno", + "libc", + "linux-raw-sys", + "windows-sys 0.61.2", +] + +[[package]] +name = "rustversion" +version = "1.0.22" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b39cdef0fa800fc44525c84ccb54a029961a8215f9619753635a9c0d2538d46d" + +[[package]] +name = "schannel" +version = "0.1.28" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "891d81b926048e76efe18581bf793546b4c0eaf8448d72be8de2bbee5fd166e1" +dependencies = [ + "windows-sys 0.61.2", +] + +[[package]] +name = "security-framework" +version = "3.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b7f4bc775c73d9a02cde8bf7b2ec4c9d12743edf609006c7facc23998404cd1d" +dependencies = [ + "bitflags", + "core-foundation", + "core-foundation-sys", + "libc", + "security-framework-sys", +] + +[[package]] +name = "security-framework-sys" +version = "2.17.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6ce2691df843ecc5d231c0b14ece2acc3efb62c0a398c7e1d875f3983ce020e3" +dependencies = [ + "core-foundation-sys", + "libc", +] + +[[package]] +name = "semver" +version = "1.0.27" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d767eb0aabc880b29956c35734170f26ed551a859dbd361d140cdbeca61ab1e2" + +[[package]] +name = "serde" +version = "1.0.228" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9a8e94ea7f378bd32cbbd37198a4a91436180c5bb472411e48b5ec2e2124ae9e" +dependencies = [ + "serde_core", + "serde_derive", +] + +[[package]] +name = "serde_core" +version = "1.0.228" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "41d385c7d4ca58e59fc732af25c3983b67ac852c1a25000afe1175de458b67ad" +dependencies = [ + "serde_derive", +] + +[[package]] +name = "serde_derive" +version = "1.0.228" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d540f220d3187173da220f885ab66608367b6574e925011a9353e4badda91d79" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "serde_json" +version = "1.0.149" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "83fc039473c5595ace860d8c4fafa220ff474b3fc6bfdb4293327f1a37e94d86" +dependencies = [ + "itoa", + "memchr", + "serde", + "serde_core", + "zmij", +] + +[[package]] +name = "shlex" +version = "1.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0fda2ff0d084019ba4d7c6f371c95d8fd75ce3524c3cb8fb653a3023f6323e64" + +[[package]] +name = "slab" +version = "0.4.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0c790de23124f9ab44544d7ac05d60440adc586479ce501c1d6d7da3cd8c9cf5" + +[[package]] +name = "smallvec" +version = "1.15.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "67b1b7a3b5fe4f1376887184045fcf45c69e92af734b7aaddc05fb777b6fbd03" + +[[package]] +name = "socket2" +version = "0.5.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e22376abed350d73dd1cd119b57ffccad95b4e585a7cda43e286245ce23c0678" +dependencies = [ + "libc", + "windows-sys 0.52.0", +] + +[[package]] +name = "socket2" +version = "0.6.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "86f4aa3ad99f2088c990dfa82d367e19cb29268ed67c574d10d0a4bfe71f07e0" +dependencies = [ + "libc", + "windows-sys 0.60.2", +] + +[[package]] +name = "stable_deref_trait" +version = "1.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6ce2be8dc25455e1f91df71bfa12ad37d7af1092ae736f3a6cd0e37bc7810596" + +[[package]] +name = "strsim" +version = "0.11.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7da8b5736845d9f2fcb837ea5d9e2628564b3b043a70948a3f0b778838c5fb4f" + +[[package]] +name = "syn" +version = "2.0.117" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e665b8803e7b1d2a727f4023456bbbbe74da67099c585258af0ad9c5013b9b99" +dependencies = [ + "proc-macro2", + "quote", + "unicode-ident", +] + +[[package]] +name = "synstructure" +version = "0.13.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "728a70f3dbaf5bab7f0c4b1ac8d7ae5ea60a4b5549c8a5914361c99147a709d2" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "tb-rs" +version = "0.1.0" +dependencies = [ + "anyhow", + "bon", + "chrono", + "clap", + "env_logger", + "http 1.4.0", + "restson", + "rpassword", + "serde", + "serde_json", + "tokio", + "url", +] + +[[package]] +name = "tempfile" +version = "3.26.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "82a72c767771b47409d2345987fda8628641887d5466101319899796367354a0" +dependencies = [ + "fastrand", + "getrandom", + "once_cell", + "rustix", + "windows-sys 0.61.2", +] + +[[package]] +name = "tinystr" +version = "0.8.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "42d3e9c45c09de15d06dd8acf5f4e0e399e85927b7f00711024eb7ae10fa4869" +dependencies = [ + "displaydoc", + "zerovec", +] + +[[package]] +name = "tokio" +version = "1.49.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "72a2903cd7736441aac9df9d7688bd0ce48edccaadf181c3b90be801e81d3d86" +dependencies = [ + "bytes", + "libc", + "mio", + "pin-project-lite", + "socket2 0.6.2", + "tokio-macros", + "windows-sys 0.61.2", +] + +[[package]] +name = "tokio-macros" +version = "2.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "af407857209536a95c8e56f8231ef2c2e2aff839b22e07a1ffcbc617e9db9fa5" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "tokio-native-tls" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bbae76ab933c85776efabc971569dd6119c580d8f5d448769dec1764bf796ef2" +dependencies = [ + "native-tls", + "tokio", +] + +[[package]] +name = "tokio-util" +version = "0.7.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9ae9cec805b01e8fc3fd2fe289f89149a9b66dd16786abd8b19cfa7b48cb0098" +dependencies = [ + "bytes", + "futures-core", + "futures-sink", + "pin-project-lite", + "tokio", +] + +[[package]] +name = "tower-service" +version = "0.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8df9b6e13f2d32c91b9bd719c00d1958837bc7dec474d94952798cc8e69eeec3" + +[[package]] +name = "tracing" +version = "0.1.44" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "63e71662fa4b2a2c3a26f570f037eb95bb1f85397f3cd8076caed2f026a6d100" +dependencies = [ + "pin-project-lite", + "tracing-core", +] + +[[package]] +name = "tracing-core" +version = "0.1.36" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "db97caf9d906fbde555dd62fa95ddba9eecfd14cb388e4f491a66d74cd5fb79a" +dependencies = [ + "once_cell", +] + +[[package]] +name = "try-lock" +version = "0.2.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e421abadd41a4225275504ea4d6566923418b7f05506fbc9c0fe86ba7396114b" + +[[package]] +name = "unicode-ident" +version = "1.0.24" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e6e4313cd5fcd3dad5cafa179702e2b244f760991f45397d14d4ebf38247da75" + +[[package]] +name = "unicode-xid" +version = "0.2.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ebc1c04c71510c7f702b52b7c350734c9ff1295c464a03335b00bb84fc54f853" + +[[package]] +name = "url" +version = "2.5.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ff67a8a4397373c3ef660812acab3268222035010ab8680ec4215f38ba3d0eed" +dependencies = [ + "form_urlencoded", + "idna", + "percent-encoding", + "serde", +] + +[[package]] +name = "utf8_iter" +version = "1.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b6c140620e7ffbb22c2dee59cafe6084a59b5ffc27a8859a5f0d494b5d52b6be" + +[[package]] +name = "utf8parse" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "06abde3611657adf66d383f00b093d7faecc7fa57071cce2578660c9f1010821" + +[[package]] +name = "vcpkg" +version = "0.2.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "accd4ea62f7bb7a82fe23066fb0957d48ef677f6eeb8215f372f52e48bb32426" + +[[package]] +name = "want" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bfa7760aed19e106de2c7c0b581b509f2f25d3dacaf737cb82ac61bc6d760b0e" +dependencies = [ + "try-lock", +] + +[[package]] +name = "wasi" +version = "0.11.1+wasi-snapshot-preview1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ccf3ec651a847eb01de73ccad15eb7d99f80485de043efb2f370cd654f4ea44b" + +[[package]] +name = "wasip2" +version = "1.0.2+wasi-0.2.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9517f9239f02c069db75e65f174b3da828fe5f5b945c4dd26bd25d89c03ebcf5" +dependencies = [ + "wit-bindgen", +] + +[[package]] +name = "wasip3" +version = "0.4.0+wasi-0.3.0-rc-2026-01-06" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5428f8bf88ea5ddc08faddef2ac4a67e390b88186c703ce6dbd955e1c145aca5" +dependencies = [ + "wit-bindgen", +] + +[[package]] +name = "wasm-bindgen" +version = "0.2.113" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "60722a937f594b7fde9adb894d7c092fc1bb6612897c46368d18e7a20208eff2" +dependencies = [ + "cfg-if", + "once_cell", + "rustversion", + "wasm-bindgen-macro", + "wasm-bindgen-shared", +] + +[[package]] +name = "wasm-bindgen-macro" +version = "0.2.113" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0fac8c6395094b6b91c4af293f4c79371c163f9a6f56184d2c9a85f5a95f3950" +dependencies = [ + "quote", + "wasm-bindgen-macro-support", +] + +[[package]] +name = "wasm-bindgen-macro-support" +version = "0.2.113" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ab3fabce6159dc20728033842636887e4877688ae94382766e00b180abac9d60" +dependencies = [ + "bumpalo", + "proc-macro2", + "quote", + "syn", + "wasm-bindgen-shared", +] + +[[package]] +name = "wasm-bindgen-shared" +version = "0.2.113" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "de0e091bdb824da87dc01d967388880d017a0a9bc4f3bdc0d86ee9f9336e3bb5" +dependencies = [ + "unicode-ident", +] + +[[package]] +name = "wasm-encoder" +version = "0.244.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "990065f2fe63003fe337b932cfb5e3b80e0b4d0f5ff650e6985b1048f62c8319" +dependencies = [ + "leb128fmt", + "wasmparser", +] + +[[package]] +name = "wasm-metadata" +version = "0.244.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bb0e353e6a2fbdc176932bbaab493762eb1255a7900fe0fea1a2f96c296cc909" +dependencies = [ + "anyhow", + "indexmap", + "wasm-encoder", + "wasmparser", +] + +[[package]] +name = "wasmparser" +version = "0.244.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "47b807c72e1bac69382b3a6fb3dbe8ea4c0ed87ff5629b8685ae6b9a611028fe" +dependencies = [ + "bitflags", + "hashbrown 0.15.5", + "indexmap", + "semver", +] + +[[package]] +name = "windows-core" +version = "0.62.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b8e83a14d34d0623b51dce9581199302a221863196a1dde71a7663a4c2be9deb" +dependencies = [ + "windows-implement", + "windows-interface", + "windows-link", + "windows-result", + "windows-strings", +] + +[[package]] +name = "windows-implement" +version = "0.60.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "053e2e040ab57b9dc951b72c264860db7eb3b0200ba345b4e4c3b14f67855ddf" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "windows-interface" +version = "0.59.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3f316c4a2570ba26bbec722032c4099d8c8bc095efccdc15688708623367e358" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "windows-link" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f0805222e57f7521d6a62e36fa9163bc891acd422f971defe97d64e70d0a4fe5" + +[[package]] +name = "windows-result" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7781fa89eaf60850ac3d2da7af8e5242a5ea78d1a11c49bf2910bb5a73853eb5" +dependencies = [ + "windows-link", +] + +[[package]] +name = "windows-strings" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7837d08f69c77cf6b07689544538e017c1bfcf57e34b4c0ff58e6c2cd3b37091" +dependencies = [ + "windows-link", +] + +[[package]] +name = "windows-sys" +version = "0.52.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "282be5f36a8ce781fad8c8ae18fa3f9beff57ec1b52cb3de0789201425d9a33d" +dependencies = [ + "windows-targets 0.52.6", +] + +[[package]] +name = "windows-sys" +version = "0.59.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1e38bc4d79ed67fd075bcc251a1c39b32a1776bbe92e5bef1f0bf1f8c531853b" +dependencies = [ + "windows-targets 0.52.6", +] + +[[package]] +name = "windows-sys" +version = "0.60.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f2f500e4d28234f72040990ec9d39e3a6b950f9f22d3dba18416c35882612bcb" +dependencies = [ + "windows-targets 0.53.5", +] + +[[package]] +name = "windows-sys" +version = "0.61.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ae137229bcbd6cdf0f7b80a31df61766145077ddf49416a728b02cb3921ff3fc" +dependencies = [ + "windows-link", +] + +[[package]] +name = "windows-targets" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9b724f72796e036ab90c1021d4780d4d3d648aca59e491e6b98e725b84e99973" +dependencies = [ + "windows_aarch64_gnullvm 0.52.6", + "windows_aarch64_msvc 0.52.6", + "windows_i686_gnu 0.52.6", + "windows_i686_gnullvm 0.52.6", + "windows_i686_msvc 0.52.6", + "windows_x86_64_gnu 0.52.6", + "windows_x86_64_gnullvm 0.52.6", + "windows_x86_64_msvc 0.52.6", +] + +[[package]] +name = "windows-targets" +version = "0.53.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4945f9f551b88e0d65f3db0bc25c33b8acea4d9e41163edf90dcd0b19f9069f3" +dependencies = [ + "windows-link", + "windows_aarch64_gnullvm 0.53.1", + "windows_aarch64_msvc 0.53.1", + "windows_i686_gnu 0.53.1", + "windows_i686_gnullvm 0.53.1", + "windows_i686_msvc 0.53.1", + "windows_x86_64_gnu 0.53.1", + "windows_x86_64_gnullvm 0.53.1", + "windows_x86_64_msvc 0.53.1", +] + +[[package]] +name = "windows_aarch64_gnullvm" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "32a4622180e7a0ec044bb555404c800bc9fd9ec262ec147edd5989ccd0c02cd3" + +[[package]] +name = "windows_aarch64_gnullvm" +version = "0.53.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a9d8416fa8b42f5c947f8482c43e7d89e73a173cead56d044f6a56104a6d1b53" + +[[package]] +name = "windows_aarch64_msvc" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "09ec2a7bb152e2252b53fa7803150007879548bc709c039df7627cabbd05d469" + +[[package]] +name = "windows_aarch64_msvc" +version = "0.53.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b9d782e804c2f632e395708e99a94275910eb9100b2114651e04744e9b125006" + +[[package]] +name = "windows_i686_gnu" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8e9b5ad5ab802e97eb8e295ac6720e509ee4c243f69d781394014ebfe8bbfa0b" + +[[package]] +name = "windows_i686_gnu" +version = "0.53.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "960e6da069d81e09becb0ca57a65220ddff016ff2d6af6a223cf372a506593a3" + +[[package]] +name = "windows_i686_gnullvm" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0eee52d38c090b3caa76c563b86c3a4bd71ef1a819287c19d586d7334ae8ed66" + +[[package]] +name = "windows_i686_gnullvm" +version = "0.53.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fa7359d10048f68ab8b09fa71c3daccfb0e9b559aed648a8f95469c27057180c" + +[[package]] +name = "windows_i686_msvc" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "240948bc05c5e7c6dabba28bf89d89ffce3e303022809e73deaefe4f6ec56c66" + +[[package]] +name = "windows_i686_msvc" +version = "0.53.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1e7ac75179f18232fe9c285163565a57ef8d3c89254a30685b57d83a38d326c2" + +[[package]] +name = "windows_x86_64_gnu" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "147a5c80aabfbf0c7d901cb5895d1de30ef2907eb21fbbab29ca94c5b08b1a78" + +[[package]] +name = "windows_x86_64_gnu" +version = "0.53.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9c3842cdd74a865a8066ab39c8a7a473c0778a3f29370b5fd6b4b9aa7df4a499" + +[[package]] +name = "windows_x86_64_gnullvm" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "24d5b23dc417412679681396f2b49f3de8c1473deb516bd34410872eff51ed0d" + +[[package]] +name = "windows_x86_64_gnullvm" +version = "0.53.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0ffa179e2d07eee8ad8f57493436566c7cc30ac536a3379fdf008f47f6bb7ae1" + +[[package]] +name = "windows_x86_64_msvc" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "589f6da84c646204747d1270a2a5661ea66ed1cced2631d546fdfb155959f9ec" + +[[package]] +name = "windows_x86_64_msvc" +version = "0.53.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d6bbff5f0aada427a1e5a6da5f1f98158182f26556f345ac9e04d36d0ebed650" + +[[package]] +name = "wit-bindgen" +version = "0.51.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d7249219f66ced02969388cf2bb044a09756a083d0fab1e566056b04d9fbcaa5" +dependencies = [ + "wit-bindgen-rust-macro", +] + +[[package]] +name = "wit-bindgen-core" +version = "0.51.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ea61de684c3ea68cb082b7a88508a8b27fcc8b797d738bfc99a82facf1d752dc" +dependencies = [ + "anyhow", + "heck", + "wit-parser", +] + +[[package]] +name = "wit-bindgen-rust" +version = "0.51.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b7c566e0f4b284dd6561c786d9cb0142da491f46a9fbed79ea69cdad5db17f21" +dependencies = [ + "anyhow", + "heck", + "indexmap", + "prettyplease", + "syn", + "wasm-metadata", + "wit-bindgen-core", + "wit-component", +] + +[[package]] +name = "wit-bindgen-rust-macro" +version = "0.51.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0c0f9bfd77e6a48eccf51359e3ae77140a7f50b1e2ebfe62422d8afdaffab17a" +dependencies = [ + "anyhow", + "prettyplease", + "proc-macro2", + "quote", + "syn", + "wit-bindgen-core", + "wit-bindgen-rust", +] + +[[package]] +name = "wit-component" +version = "0.244.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9d66ea20e9553b30172b5e831994e35fbde2d165325bec84fc43dbf6f4eb9cb2" +dependencies = [ + "anyhow", + "bitflags", + "indexmap", + "log", + "serde", + "serde_derive", + "serde_json", + "wasm-encoder", + "wasm-metadata", + "wasmparser", + "wit-parser", +] + +[[package]] +name = "wit-parser" +version = "0.244.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ecc8ac4bc1dc3381b7f59c34f00b67e18f910c2c0f50015669dde7def656a736" +dependencies = [ + "anyhow", + "id-arena", + "indexmap", + "log", + "semver", + "serde", + "serde_derive", + "serde_json", + "unicode-xid", + "wasmparser", +] + +[[package]] +name = "writeable" +version = "0.6.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9edde0db4769d2dc68579893f2306b26c6ecfbe0ef499b013d731b7b9247e0b9" + +[[package]] +name = "yoke" +version = "0.8.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "72d6e5c6afb84d73944e5cedb052c4680d5657337201555f9f2a16b7406d4954" +dependencies = [ + "stable_deref_trait", + "yoke-derive", + "zerofrom", +] + +[[package]] +name = "yoke-derive" +version = "0.8.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b659052874eb698efe5b9e8cf382204678a0086ebf46982b79d6ca3182927e5d" +dependencies = [ + "proc-macro2", + "quote", + "syn", + "synstructure", +] + +[[package]] +name = "zerofrom" +version = "0.1.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "50cc42e0333e05660c3587f3bf9d0478688e15d870fab3346451ce7f8c9fbea5" +dependencies = [ + "zerofrom-derive", +] + +[[package]] +name = "zerofrom-derive" +version = "0.1.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d71e5d6e06ab090c67b5e44993ec16b72dcbaabc526db883a360057678b48502" +dependencies = [ + "proc-macro2", + "quote", + "syn", + "synstructure", +] + +[[package]] +name = "zerotrie" +version = "0.2.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2a59c17a5562d507e4b54960e8569ebee33bee890c70aa3fe7b97e85a9fd7851" +dependencies = [ + "displaydoc", + "yoke", + "zerofrom", +] + +[[package]] +name = "zerovec" +version = "0.11.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6c28719294829477f525be0186d13efa9a3c602f7ec202ca9e353d310fb9a002" +dependencies = [ + "yoke", + "zerofrom", + "zerovec-derive", +] + +[[package]] +name = "zerovec-derive" +version = "0.11.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "eadce39539ca5cb3985590102671f2567e659fca9666581ad3411d59207951f3" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "zmij" +version = "1.0.21" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b8848ee67ecc8aedbaf3e4122217aff892639231befc6a1b58d29fff4c2cabaa" diff --git a/cli/Cargo.toml b/cli/Cargo.toml new file mode 100644 index 0000000..f9349f9 --- /dev/null +++ b/cli/Cargo.toml @@ -0,0 +1,18 @@ +[package] +name = "tb-rs" +version = "0.1.0" +edition = "2024" + +[dependencies] +anyhow = "1.0.102" +bon = "3.9.0" +chrono = { version = "0.4.44", features = ["serde"] } +clap = { version = "4.5.60", features = ["cargo", "derive", "env" ] } +env_logger = "0.11.9" +http = "1.4.0" +restson = "1.5.0" +rpassword = "7.4.0" +serde = { version = "1.0.228", features = ["derive"] } +serde_json = "1.0.149" +tokio = { version = "1.49.0", features = ["macros", "rt-multi-thread"] } +url = "2.5.8" diff --git a/cli/src/api/mod.rs b/cli/src/api/mod.rs new file mode 100644 index 0000000..8e8c7e6 --- /dev/null +++ b/cli/src/api/mod.rs @@ -0,0 +1,78 @@ +//use bon::Builder; +//use chrono::{DateTime,Utc}; +//use restson::{RestClient, RestPath, Error}; +// +//pub enum Order { +// Ascending, +// Descending, +//} +// +//impl AsRef for Order { +// fn as_ref(&self) -> &str { +// match self { +// Self::Ascending => "asc", +// Self::Descending => "desc", +// } +// } +//} +// +//impl From for Order { +// fn from(ascending: bool) -> Self { +// if ascending { +// Self::Ascending +// } else { +// Self::Descending +// } +// } +//} +// +#[derive(serde::Deserialize)] +pub struct Spond { + id: String, + +} +// +//#[bon::builder] +//#[builder(on(bool, default=false))] +//fn sponds( +// comments: bool, +// hidden: bool, +// add_profile_info: bool, +// scheduled=bool, +// #[builder(into)] +// order=Order, +// #[builder(default = 20)] +// max=usize, +// min_end_timestamp=Option>, +// max_end_timestamp=Option>, +//) -> Get<(), Vec> { +// +//} +// +//struct Sponds(Query); +// +//async pub fn sponds( +// #[builder(finish_fn)] +// client: &restson::RestClient, E +// +// + +crate::get!(search(), () => "sponds" -> Vec); + +//impl Search { +// with_comments( +//#[bon::builder] +//#[builder(on(bool, default=false))] +//fn sponds( +// comments: bool, +// hidden: bool, +// add_profile_info: bool, +// scheduled=bool, +// #[builder(into)] +// order=Order, +// #[builder(default = 20)] +// max=usize, +// min_end_timestamp=Option>, +// max_end_timestamp=Option>, +//) -> Search { +//} diff --git a/cli/src/authentication.rs b/cli/src/authentication.rs new file mode 100644 index 0000000..2f0c42b --- /dev/null +++ b/cli/src/authentication.rs @@ -0,0 +1,165 @@ +use clap::{Args, ArgGroup}; +use restson::{RestClient, RestPath, Response}; +use anyhow::{Result, Error}; +use serde::{ + ser::{Serialize, Serializer, SerializeMap}, + Deserialize, +}; +use chrono::{DateTime, Utc}; + +#[derive(Args, Debug)] +#[command(group( + ArgGroup::new("authentication") + .args(["access", "refresh", "email", "phone"]) +))] +pub struct Authentication { + #[arg(long)] + access: Option, + + #[arg(long)] + refresh: Option, + + #[arg(long)] + email: Option, + + #[arg(long)] + phone: Option, +} + +impl Authentication { + pub async fn apply(self, client: RestClient) -> Result { + let client = match (self.access, self.refresh, self.email, self.phone) { + (Some(v), None, None, None) => v.apply(client)?, + (None, Some(v), None, None) => Tokens::authenticate(client, v).await?, + (None, None, Some(v), None) => Tokens::authenticate(client, v).await?, + (None, None, None, Some(v)) => Tokens::authenticate(client, v).await?, + (None, None, None, None) => client, + (a, b, c, d) => anyhow::bail!("invalid authentication: {} + {} + {} + {}", a.is_some(), b.is_some(), c.is_some(), d.is_some()), + }; + Ok(client) + } +} + +mod identifier { + #[derive(Debug, Clone)] + pub struct Email; + #[derive(Debug, Clone)] + pub struct Phone; +} + +trait Identifier: Clone { + const NAME: &'static str; + type Value: std::str::FromStr + std::fmt::Debug + Clone + serde::Serialize; + type Error: std::error::Error + Send + Sync + 'static; +} + +impl Identifier for identifier::Email { + const NAME: &'static str = "email"; + type Value = String; + type Error = ::Err; +} + +impl Identifier for identifier::Phone { + const NAME: &'static str = "phone"; + type Value = String; + type Error = ::Err; +} + +#[derive(Debug, Clone)] +struct WithPassword { + value: I::Value, + password: String, +} + +impl Serialize for WithPassword { + fn serialize(&self, serializer: S) -> Result + { + let mut map = serializer.serialize_map(Some(2))?; + map.serialize_entry(I::NAME, &self.value)?; + map.serialize_entry("password", &self.password)?; + map.end() + } +} + +impl RestPath<()> for WithPassword { + fn get_path(_: ()) -> std::result::Result { + Ok(String::from("auth2/login")) + } +} + +type Email = WithPassword; +type Phone = WithPassword; + +impl std::str::FromStr for WithPassword { + type Err= Error; + + fn from_str(s: &str) -> Result { + let password = match std::env::var("SPOND_PASSWORD") { + Ok(password) => password, + Err(_) => rpassword::prompt_password("Password: ")?, + }; + let value = I::Value::from_str(s)?; + Ok(Self { value, password }) + } +} + +#[derive(Debug, Deserialize)] +struct Tokens { + #[serde(rename = "accessToken")] + access: TokenWithExpiration, + #[serde(rename = "refreshToken")] + refresh: TokenWithExpiration, +} + +impl Tokens { + async fn authenticate>(client: RestClient, request: R) -> Result { + let tokens: Response = client.post_capture((), &request).await?; + tokens.into_inner().apply(client) + } + + fn apply(self, client: RestClient) -> Result { + println!("refresh: {self:?}"); + self.access.token.apply(client) + } + +} + +#[derive(Debug, Deserialize)] +struct TokenWithExpiration { + token: Token, + #[allow(unused)] + expiration: DateTime +} + +#[derive(Debug, Clone, Deserialize)] +struct Token(String); + +impl Serialize for Token { + fn serialize(&self, serializer: S) -> Result + { + let mut map = serializer.serialize_map(Some(1))?; + map.serialize_entry("token", &self.0)?; + map.end() + } +} + +impl Token { + fn apply(self, mut client: RestClient) -> Result { + client.set_header("Authorization", &format!("Bearer {}", self.0))?; + Ok(client) + } +} + +impl RestPath<()> for Token { + fn get_path(_: ()) -> std::result::Result { + Ok(String::from("auth2/login/refresh")) + } +} + +impl std::str::FromStr for Token { + type Err = std::convert::Infallible; + + fn from_str(s: &str) -> Result { + Ok(Self(s.to_string())) + } +} diff --git a/cli/src/main.rs b/cli/src/main.rs new file mode 100644 index 0000000..452bc17 --- /dev/null +++ b/cli/src/main.rs @@ -0,0 +1,62 @@ +use clap::Parser; +use restson::RestClient; +use anyhow::Result; +use url::Url; + +mod authentication; +mod api; + +mod request; + +#[derive(Parser, Debug)] +#[command(author, version, about)] +struct Cli { + #[command(flatten)] + authentication: authentication::Authentication, + + #[arg(long, default_value = "https://api.spond.com/")] + base: Url, +} + +impl Cli { + pub async fn client(self) -> Result { + let base = self.base.join("/core/v1/")?; + let client = RestClient::new(base.as_str())?; + Ok(self.authentication.apply(client).await?) + } +} + +#[derive(Debug, serde::Deserialize)] +struct Spond(serde_json::Value); + +#[derive(Debug, serde::Deserialize)] +struct Sponds(Vec); + +impl restson::RestPath<()> for Sponds { + fn get_path(_: ()) -> std::result::Result { + Ok(String::from("sponds")) + } +} + +#[tokio::main] +async fn main() -> Result<()> { + env_logger::init(); + + let client = Cli::parse().client().await?; + + // https://api.spond.com/core/v1/sponds?includeComments=true&includeHidden=false&addProfileInfo=true&scheduled=true&order=asc&max=20&prevId=F94829E35A9B4A48A042646C8B658B01&minStartTimestamp=2026-04-11T09:45:00Z&minEndTimestamp=2026-02-26T23:00:00.001Z + let query = [ + ("includeComments", "true"), + ("includeHidden", "false"), + ("addProfileInfo", "true"), + ("scheduled", "true"), + ("order", "asc"), + ("max", "20"), + ]; + + for spond in client.get_with::<_, Sponds>((), &query).await?.into_inner().0 { + println!("{spond:?}"); + } + + Ok(()) +} diff --git a/cli/src/request/get.rs b/cli/src/request/get.rs new file mode 100644 index 0000000..78b7f53 --- /dev/null +++ b/cli/src/request/get.rs @@ -0,0 +1,111 @@ +/// GET macro +#[macro_export] +macro_rules! get { + // Case 1: no query + ( + $name:ident, + ( $( $arg:ident : $arg_ty:ty ),* ) => $path:literal -> $out:ty $(,)? + ) => { + get!($name(), ( $( $arg : $arg_ty ),* ) => $path -> $out); + }; + + // Case 2: empty query () + ( + $name:ident (), + ( $( $arg:ident : $arg_ty:ty ),* ) => $path:literal -> $out:ty $(,)? + ) => { + #[bon::builder] + pub fn $name( + #[builder(finish_fn)] client: &restson::RestClient, + $( #[builder(finish_fn)] $arg: $arg_ty ),* + ) -> impl std::future::Future> + '_ { + #[derive(serde::Deserialize)] + struct RP($out); + + impl restson::RestPath<( $( $arg_ty ),* )> for RP { + fn get_path(args: ( $( $arg_ty ),* )) -> Result { + let ( $( $arg ),* ) = args; + Ok(format!($path, $( $arg = $arg ),* )) + } + } + + async move { + let result = client.get_with::<_, RP>(( $( $arg ),* ), &[]).await?; + Ok(result.into_inner().0) + } + } + }; + + // Case 3: query with flags / mixed types + ( + $name:ident ( $( $query:tt ),* $(,)? ), + ( $( $arg:ident : $arg_ty:ty ),* ) => $path:literal -> $out:ty $(,)? + ) => { + #[bon::builder] + pub fn $name( + #[builder(finish_fn)] client: &restson::RestClient, + $( #[builder(finish_fn)] $arg: $arg_ty, )* + $( + get!(@query_field $query) + )* + ) -> impl std::future::Future> + '_ { + #[derive(serde::Serialize)] + #[serde(rename_all = "camelCase")] + struct Query<'a> { + $( + get!(@query_field_struct $query) + )* + } + + impl Query<'_> { + fn as_pairs(&self) -> Vec<(&str, String)> { + let mut out = Vec::new(); + $( + get!(@push_pair out, self, $query) + )* + out + } + } + + let query = Query { + $( + get!(@query_field_init $query) + )* + }; + + #[derive(serde::Deserialize)] + struct RP($out); + + impl restson::RestPath<( $( $arg_ty ),* )> for RP { + fn get_path(args: ( $( $arg_ty ),* )) -> Result { + let ( $( $arg ),* ) = args; + Ok(format!($path, $( $arg = $arg ),* )) + } + } + + async move { + let result = client.get_with::<_, RP>(&query.as_pairs(), ( $( $arg ),* )).await?; + Ok(result.0) + } + } + }; + + // Query helpers + (@query_field $field:ident) => { $field: Option, }; + (@query_field $field:ident = $ty:ty) => { $field: $ty, }; + + (@query_field_struct $field:ident) => { $field: Option, }; + (@query_field_struct $field:ident = $ty:ty) => { $field: $ty, }; + + (@query_field_init $field:ident) => { $field, }; + (@query_field_init $field:ident = $ty:ty) => { $field, }; + + (@push_pair $vec:ident, $self:ident, $field:ident = $ty:ty) => { + $vec.push((stringify!($field), $self.$field.to_string())); + }; + (@push_pair $vec:ident, $self:ident, $field:ident) => { + if let Some(v) = &$self.$field { + $vec.push((stringify!($field), v.to_string())); + } + }; +} diff --git a/cli/src/request/mod.rs b/cli/src/request/mod.rs new file mode 100644 index 0000000..69e599d --- /dev/null +++ b/cli/src/request/mod.rs @@ -0,0 +1,2 @@ +pub mod get; +pub mod post; diff --git a/cli/src/request/post.rs b/cli/src/request/post.rs new file mode 100644 index 0000000..eab1fce --- /dev/null +++ b/cli/src/request/post.rs @@ -0,0 +1,85 @@ +/// Generate a POST function +#[macro_export] +macro_rules! post { + ( + $name:ident ( $( $query:tt ),* $(,)? ), + $( $body:ident = $body_ty:ty ),* $(,)?, + ( $( $arg:ident : $arg_ty:ty ),* ) => $path:expr $(,)? + ) => { + #[bon::builder] + pub fn $name( + #[builder(finish_fn)] + client: &restson::Client, + $( #[builder(finish_fn)] $arg: $arg_ty, )* + $( + post!(@query_field $query) + )* + $( + $body: $body_ty, + )* + ) -> impl std::future::Future> + '_ + { + // Query struct + #[derive(serde::Serialize)] + #[serde(rename_all = "camelCase")] + struct Query<'a> { + $( + post!(@query_field_struct $query) + )* + } + + // Body struct + #[derive(serde::Serialize)] + #[serde(rename_all = "camelCase")] + struct Body<'a> { + $( + $body: $body_ty, + )* + } + + let query = Query { + $( + post!(@query_field_init $query) + )* + }; + + let body = Body { + $( + $body, + )* + }; + + impl restson::RestPath<( $( $arg_ty ),* )> for Body<'_> { + fn get_url($( $arg: $arg_ty ),*) -> Result { + Ok(format!($path, $( $arg = $arg ),* )) + } + } + + client.post_capture_with::<_, _, _>(&body, &query, ( $( $arg ),* )) + } + }; + + // Helper: parse query field plain vs typed + (@query_field $field:ident) => { + $field: Option, + }; + (@query_field $field:ident = $ty:ty) => { + $field: $ty, + }; + + // Helper: struct fields + (@query_field_struct $field:ident) => { + $field: Option, + }; + (@query_field_struct $field:ident = $ty:ty) => { + $field: $ty, + }; + + // Helper: initialize query fields + (@query_field_init $field:ident) => { + $field, + }; + (@query_field_init $field:ident = $ty:ty) => { + $field, + }; +} From d9725470590afe574b0d486bd5d61eda9c832e7c Mon Sep 17 00:00:00 2001 From: Jonas Rabenstein Date: Fri, 27 Feb 2026 03:34:25 +0100 Subject: [PATCH 03/15] wip --- cli/src/api/mod.rs | 12 +++++++++++- cli/src/request/get.rs | 5 ++--- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/cli/src/api/mod.rs b/cli/src/api/mod.rs index 8e8c7e6..34d9acb 100644 --- a/cli/src/api/mod.rs +++ b/cli/src/api/mod.rs @@ -57,7 +57,17 @@ pub struct Spond { // // -crate::get!(search(), () => "sponds" -> Vec); +crate::get!(search( + comments: bool, + hidden: bool, + add_profile_info: bool, + scheduled: bool, + #[builder(into)] order: Order, + #[builder(default=20)]max: usize, + ), + min_end_timestamp: Option>, + max_end_timestamp: Option>, + () => "sponds" -> Vec); //impl Search { // with_comments( diff --git a/cli/src/request/get.rs b/cli/src/request/get.rs index 78b7f53..0c9ff3b 100644 --- a/cli/src/request/get.rs +++ b/cli/src/request/get.rs @@ -1,4 +1,3 @@ -/// GET macro #[macro_export] macro_rules! get { // Case 1: no query @@ -84,8 +83,8 @@ macro_rules! get { } async move { - let result = client.get_with::<_, RP>(&query.as_pairs(), ( $( $arg ),* )).await?; - Ok(result.0) + let result = client.get_with::<_, RP>(( $( $arg ),* ), &query.as_pairs()).await?; + Ok(result.into_inner().0) } } }; From a03c1891c86c4ccc7960e2456f6f73e51adfd796 Mon Sep 17 00:00:00 2001 From: Jonas Rabenstein Date: Fri, 27 Feb 2026 05:46:12 +0100 Subject: [PATCH 04/15] v1 --- macros/Cargo.toml | 12 +++++ macros/src/lib.rs | 109 ++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 121 insertions(+) create mode 100644 macros/Cargo.toml create mode 100644 macros/src/lib.rs diff --git a/macros/Cargo.toml b/macros/Cargo.toml new file mode 100644 index 0000000..38091e7 --- /dev/null +++ b/macros/Cargo.toml @@ -0,0 +1,12 @@ +[package] +name = "spond-macros" +version = "0.1.0" +edition = "2024" + +[lib] +proc-macro = true + +[dependencies] +proc-macro2 = "1.0.106" +quote = "1.0.44" +syn = { version = "2.0.117", features = ["extra-traits", "full"] } diff --git a/macros/src/lib.rs b/macros/src/lib.rs new file mode 100644 index 0000000..4b489f0 --- /dev/null +++ b/macros/src/lib.rs @@ -0,0 +1,109 @@ +use proc_macro::TokenStream; +use quote::{quote, ToTokens}; +use syn::{ + parse_macro_input, Attribute, FnArg, ItemFn, Lit, Meta, Pat, PatType, Type, spanned::Spanned, +}; + +/// Endpoint macro +#[proc_macro_attribute] +pub fn endpoint(attr: TokenStream, item: TokenStream) -> TokenStream { + // parse the endpoint attribute + let attr = proc_macro2::TokenStream::from(attr); + let func = parse_macro_input!(item as ItemFn); + + let vis = &func.vis; + let name = &func.sig.ident; + let inputs = &func.sig.inputs; + let output = &func.sig.output; + + // must be async + if func.sig.asyncness.is_none() { + return syn::Error::new(name.span(), "endpoint function must be async") + .to_compile_error() + .into(); + } + + // defaults + let mut method = quote! { GET }; + let mut path = None; + + // parse #[endpoint(...)] + if !attr.is_empty() { + let attr_str = attr.to_string(); + // simple heuristic: if contains "POST", switch + if attr_str.contains("POST") { + method = quote! { POST }; + } + // simple heuristic: extract path in quotes + if let Some(start) = attr_str.find('"') { + if let Some(end) = attr_str[start+1..].find('"') { + path = Some(attr_str[start+1..start+1+end].to_string()); + } + } + } + + let path = match path { + Some(p) => p, + None => return syn::Error::new(name.span(), "endpoint path must be provided") + .to_compile_error() + .into(), + }; + + // process arguments + let mut client_arg = None; + let mut other_args = Vec::new(); + + for input in inputs { + match input { + FnArg::Receiver(_) => continue, // skip self + FnArg::Typed(PatType { pat, ty, .. }) => { + if let Pat::Ident(ident) = &**pat { + if ident.ident == "client" { + client_arg = Some((ident.ident.clone(), ty)); + } else { + other_args.push((ident.ident.clone(), ty)); + } + } + } + } + } + + // generate tokens for function with builder + let arg_defs: Vec = other_args.iter().map(|(id, ty)| { + // wrap Option with #[builder(default)] + if let Type::Path(tp) = ty.as_ref() { + let is_option = tp.path.segments.last().map(|seg| seg.ident == "Option").unwrap_or(false); + if is_option { + quote! { #[builder(default)] #id: #ty } + } else { + quote! { #id: #ty } + } + } else { + quote! { #id: #ty } + } + }).collect(); + + let client_def = match client_arg { + Some((id, ty)) => quote! { #[builder(finish_fn)] #id: #ty }, + None => quote! { #[builder(finish_fn)] client: &restson::RestClient }, + }; + + let call_args: Vec = other_args.iter().map(|(id, _)| { + quote! { #id } + }).collect(); + + let expanded = quote! { + #[bon::builder] + #vis fn #name( + #client_def, + #(#arg_defs),* + ) -> impl std::future::Future> + '_ { + async move { + let result = client.get::<_, serde_json::Value>(#path).await?; + Ok(result) + } + } + }; + + expanded.into() +} From a0ddaf89a950363eaa88a4a5858ff41d2f0b1ebb Mon Sep 17 00:00:00 2001 From: Jonas Rabenstein Date: Fri, 27 Feb 2026 05:52:35 +0100 Subject: [PATCH 05/15] v2 --- cli/Cargo.toml | 1 + cli/src/api/mod.rs | 93 +++++++++++++---------- cli/src/main.rs | 34 ++++++--- cli/src/request/get.rs | 70 ++++++----------- macros/src/lib.rs | 167 +++++++++++++++++++++++------------------ 5 files changed, 197 insertions(+), 168 deletions(-) diff --git a/cli/Cargo.toml b/cli/Cargo.toml index f9349f9..389ce79 100644 --- a/cli/Cargo.toml +++ b/cli/Cargo.toml @@ -14,5 +14,6 @@ restson = "1.5.0" rpassword = "7.4.0" serde = { version = "1.0.228", features = ["derive"] } serde_json = "1.0.149" +spond-macros = { version = "0.1.0", path = "../macros" } tokio = { version = "1.49.0", features = ["macros", "rt-multi-thread"] } url = "2.5.8" diff --git a/cli/src/api/mod.rs b/cli/src/api/mod.rs index 34d9acb..be81c07 100644 --- a/cli/src/api/mod.rs +++ b/cli/src/api/mod.rs @@ -1,32 +1,34 @@ //use bon::Builder; -//use chrono::{DateTime,Utc}; +use chrono::{DateTime,Utc}; +use serde::{Serialize, Deserialize}; //use restson::{RestClient, RestPath, Error}; // -//pub enum Order { -// Ascending, -// Descending, -//} -// -//impl AsRef for Order { -// fn as_ref(&self) -> &str { -// match self { -// Self::Ascending => "asc", -// Self::Descending => "desc", -// } -// } -//} -// -//impl From for Order { -// fn from(ascending: bool) -> Self { -// if ascending { -// Self::Ascending -// } else { -// Self::Descending -// } -// } -//} -// -#[derive(serde::Deserialize)] +#[derive(Serialize)] +pub enum Order { + Ascending, + Descending, +} + +impl AsRef for Order { + fn as_ref(&self) -> &str { + match self { + Self::Ascending => "asc", + Self::Descending => "desc", + } + } +} + +impl From for Order { + fn from(ascending: bool) -> Self { + if ascending { + Self::Ascending + } else { + Self::Descending + } + } +} + +#[derive(Debug, Deserialize)] pub struct Spond { id: String, @@ -46,29 +48,42 @@ pub struct Spond { // min_end_timestamp=Option>, // max_end_timestamp=Option>, //) -> Get<(), Vec> { -// -//} -// -//struct Sponds(Query); -// -//async pub fn sponds( -// #[builder(finish_fn)] -// client: &restson::RestClient, E -// -// -crate::get!(search( +//crate::get!(sponds( +// comments: bool, +// hidden: bool, +// add_profile_info: bool, +// scheduled, +// #[builder(into, default=Order::Ascending)] order: Order, +// #[builder(default=20)]max: usize, +// min_end_timestamp: Option>, +// max_end_timestamp: Option>, +// ), +// () => "sponds" -> Vec); + +#[spond_macros::endpoint((id:u128):"/spond/{id:032X}/info", (eid:u128, uid:u128): "/spond/{eid:032X}/response/{uid:032X}")] +pub async fn sponds(result: serde_json::Value, + #[query] comments: Option, + #[query] hidden: Option, + #[body] min_end_timestamp: Option>, +) -> serde_json::Value { + result +} + + +/* +crate::post!(post( comments: bool, hidden: bool, add_profile_info: bool, scheduled: bool, #[builder(into)] order: Order, #[builder(default=20)]max: usize, - ), + ) min_end_timestamp: Option>, max_end_timestamp: Option>, () => "sponds" -> Vec); - +*/ //impl Search { // with_comments( //#[bon::builder] diff --git a/cli/src/main.rs b/cli/src/main.rs index 452bc17..f964c60 100644 --- a/cli/src/main.rs +++ b/cli/src/main.rs @@ -45,17 +45,29 @@ async fn main() -> Result<()> { let client = Cli::parse().client().await?; // https://api.spond.com/core/v1/sponds?includeComments=true&includeHidden=false&addProfileInfo=true&scheduled=true&order=asc&max=20&prevId=F94829E35A9B4A48A042646C8B658B01&minStartTimestamp=2026-04-11T09:45:00Z&minEndTimestamp=2026-02-26T23:00:00.001Z - let query = [ - ("includeComments", "true"), - ("includeHidden", "false"), - ("addProfileInfo", "true"), - ("scheduled", "true"), - ("order", "asc"), - ("max", "20"), - ]; - - for spond in client.get_with::<_, Sponds>((), &query).await?.into_inner().0 { - println!("{spond:?}"); + if false { + let query = [ + ("includeComments", "true"), + ("includeHidden", "false"), + ("addProfileInfo", "true"), + ("scheduled", "true"), + ("order", "asc"), + ("max", "20"), + ]; + + for spond in client.get_with::<_, Sponds>((), &query).await?.into_inner().0 { + println!("{spond:?}"); + } + } else { + let request = api::sponds() + .comments(true) + .hidden(false) + .add_profile_info(false) + .scheduled(true) + ; + for spond in request.call(&client).await? { + println!("{spond:?}"); + } } Ok(()) diff --git a/cli/src/request/get.rs b/cli/src/request/get.rs index 0c9ff3b..4817767 100644 --- a/cli/src/request/get.rs +++ b/cli/src/request/get.rs @@ -3,7 +3,7 @@ macro_rules! get { // Case 1: no query ( $name:ident, - ( $( $arg:ident : $arg_ty:ty ),* ) => $path:literal -> $out:ty $(,)? + ( $( $arg:ident : $arg_ty:ty ),* $(,)? ) => $path:literal -> $out:ty ) => { get!($name(), ( $( $arg : $arg_ty ),* ) => $path -> $out); }; @@ -11,7 +11,7 @@ macro_rules! get { // Case 2: empty query () ( $name:ident (), - ( $( $arg:ident : $arg_ty:ty ),* ) => $path:literal -> $out:ty $(,)? + ( $( $arg:ident : $arg_ty:ty ),* $(,)? ) => $path:literal -> $out:ty ) => { #[bon::builder] pub fn $name( @@ -35,42 +35,30 @@ macro_rules! get { } }; - // Case 3: query with flags / mixed types + // Case 3: query with optional attributes ( - $name:ident ( $( $query:tt ),* $(,)? ), - ( $( $arg:ident : $arg_ty:ty ),* ) => $path:literal -> $out:ty $(,)? + $name:ident ( $( $(#[$attr:meta])* $query_ident:ident $(: $query_ty:ty )? ),* $(,)? ), + ( $( $arg:ident : $arg_ty:ty ),* $(,)? ) => $path:literal -> $out:ty ) => { #[bon::builder] pub fn $name( #[builder(finish_fn)] client: &restson::RestClient, $( #[builder(finish_fn)] $arg: $arg_ty, )* $( - get!(@query_field $query) + $(#[$attr])* $query_ident : $crate::get!( @query_type $( $query_ty )? ) , )* ) -> impl std::future::Future> + '_ { - #[derive(serde::Serialize)] - #[serde(rename_all = "camelCase")] - struct Query<'a> { - $( - get!(@query_field_struct $query) - )* - } - impl Query<'_> { - fn as_pairs(&self) -> Vec<(&str, String)> { - let mut out = Vec::new(); - $( - get!(@push_pair out, self, $query) - )* - out - } - } - - let query = Query { + // Build Vec<(String,String)> dynamically using serde_json::to_string + let query_pairs: Vec<(String, String)> = vec![ $( - get!(@query_field_init $query) - )* - }; + { + let val = serde_json::to_string(&$query_ident) + .expect("failed to serialize query param"); + (stringify!($query_ident).to_string(), val) + } + ),* + ]; #[derive(serde::Deserialize)] struct RP($out); @@ -83,28 +71,18 @@ macro_rules! get { } async move { - let result = client.get_with::<_, RP>(( $( $arg ),* ), &query.as_pairs()).await?; + // Convert Vec<(String,String)> to Vec<(&str,&str)> + let ref_pairs: Vec<(&str, &str)> = query_pairs + .iter() + .map(|(k, v)| (k.as_str(), v.as_str())) + .collect(); + + let result = client.get_with::<_, RP>(( $( $arg ),* ), &ref_pairs).await?; Ok(result.into_inner().0) } } }; - // Query helpers - (@query_field $field:ident) => { $field: Option, }; - (@query_field $field:ident = $ty:ty) => { $field: $ty, }; - - (@query_field_struct $field:ident) => { $field: Option, }; - (@query_field_struct $field:ident = $ty:ty) => { $field: $ty, }; - - (@query_field_init $field:ident) => { $field, }; - (@query_field_init $field:ident = $ty:ty) => { $field, }; - - (@push_pair $vec:ident, $self:ident, $field:ident = $ty:ty) => { - $vec.push((stringify!($field), $self.$field.to_string())); - }; - (@push_pair $vec:ident, $self:ident, $field:ident) => { - if let Some(v) = &$self.$field { - $vec.push((stringify!($field), v.to_string())); - } - }; + ( @query_type ) => { Option }; + ( @query_type $ty:ty) => { $ty }; } diff --git a/macros/src/lib.rs b/macros/src/lib.rs index 4b489f0..93fe0cb 100644 --- a/macros/src/lib.rs +++ b/macros/src/lib.rs @@ -1,109 +1,132 @@ use proc_macro::TokenStream; -use quote::{quote, ToTokens}; +use quote::quote; use syn::{ - parse_macro_input, Attribute, FnArg, ItemFn, Lit, Meta, Pat, PatType, Type, spanned::Spanned, + parse_macro_input, FnArg, ItemFn, LitStr, Pat, PatType, Type, Attribute, spanned::Spanned, }; -/// Endpoint macro +/// Path args parser for `#[endpoint((x:u128,y:String): "/path/{x}/{y}")]` +struct EndpointPath { + args: Vec<(syn::Ident, syn::Type)>, + path: LitStr, +} + +impl syn::parse::Parse for EndpointPath { + fn parse(input: syn::parse::ParseStream) -> syn::Result { + let content; + syn::parenthesized!(content in input); + + let mut args = Vec::new(); + while !content.is_empty() { + let ident: syn::Ident = content.parse()?; + content.parse::()?; + let ty: syn::Type = content.parse()?; + args.push((ident, ty)); + + if content.peek(syn::Token![,]) { + content.parse::()?; + } + } + + input.parse::()?; + let path: LitStr = input.parse()?; + + Ok(EndpointPath { args, path }) + } +} + #[proc_macro_attribute] pub fn endpoint(attr: TokenStream, item: TokenStream) -> TokenStream { - // parse the endpoint attribute - let attr = proc_macro2::TokenStream::from(attr); + let path_args = parse_macro_input!(attr as EndpointPath); let func = parse_macro_input!(item as ItemFn); let vis = &func.vis; let name = &func.sig.ident; - let inputs = &func.sig.inputs; let output = &func.sig.output; - // must be async - if func.sig.asyncness.is_none() { - return syn::Error::new(name.span(), "endpoint function must be async") - .to_compile_error() - .into(); - } + // Separate query/body args + let mut query_fields = Vec::new(); + let mut body_fields = Vec::new(); - // defaults - let mut method = quote! { GET }; - let mut path = None; + for arg in &func.sig.inputs { + if let FnArg::Typed(PatType { pat, ty, attrs, .. }) = arg { + let pat_ident = match &**pat { + Pat::Ident(pi) => &pi.ident, + _ => continue, + }; - // parse #[endpoint(...)] - if !attr.is_empty() { - let attr_str = attr.to_string(); - // simple heuristic: if contains "POST", switch - if attr_str.contains("POST") { - method = quote! { POST }; - } - // simple heuristic: extract path in quotes - if let Some(start) = attr_str.find('"') { - if let Some(end) = attr_str[start+1..].find('"') { - path = Some(attr_str[start+1..start+1+end].to_string()); + if attrs.iter().any(|a| a.path().is_ident("query")) { + query_fields.push((pat_ident.clone(), (*ty).clone(), attrs.clone())); + } else if attrs.iter().any(|a| a.path().is_ident("body")) { + body_fields.push((pat_ident.clone(), (*ty).clone(), attrs.clone())); } } } - let path = match path { - Some(p) => p, - None => return syn::Error::new(name.span(), "endpoint path must be provided") - .to_compile_error() - .into(), - }; + // Path args + let path_idents: Vec<_> = path_args.args.iter().map(|(i, _)| i).collect(); + let path_types: Vec<_> = path_args.args.iter().map(|(_, t)| t).collect(); + let path_fmt = &path_args.path; - // process arguments - let mut client_arg = None; - let mut other_args = Vec::new(); - - for input in inputs { - match input { - FnArg::Receiver(_) => continue, // skip self - FnArg::Typed(PatType { pat, ty, .. }) => { - if let Pat::Ident(ident) = &**pat { - if ident.ident == "client" { - client_arg = Some((ident.ident.clone(), ty)); - } else { - other_args.push((ident.ident.clone(), ty)); - } - } + // Build query serialization + let query_pairs = query_fields.iter().map(|(ident, _, _)| { + quote! { + if let Some(v) = &#ident { + query_pairs.push((stringify!(#ident), v.to_string())); } } - } + }); - // generate tokens for function with builder - let arg_defs: Vec = other_args.iter().map(|(id, ty)| { - // wrap Option with #[builder(default)] - if let Type::Path(tp) = ty.as_ref() { - let is_option = tp.path.segments.last().map(|seg| seg.ident == "Option").unwrap_or(false); - if is_option { - quote! { #[builder(default)] #id: #ty } + // Build body serialization + let body_pairs = body_fields.iter().map(|(ident, _, _)| { + quote! { + body_map.insert(stringify!(#ident).to_string(), serde_json::to_value(&#ident)?); + } + }); + + // Determine method + let method = if body_fields.is_empty() { quote! { GET } } else { quote! { POST } }; + + // Expand query/body fields for function signature + let query_sig = query_fields.iter().map(|(ident, ty, _attrs)| { + if let Type::Path(tp) = &**ty { // <-- dereference the Box + if tp.path.segments.last().unwrap().ident == "Option" { + quote! { #[builder(default)] #ident: #ty } } else { - quote! { #id: #ty } + quote! { #ident: #ty } } } else { - quote! { #id: #ty } + quote! { #ident: #ty } } - }).collect(); + }); - let client_def = match client_arg { - Some((id, ty)) => quote! { #[builder(finish_fn)] #id: #ty }, - None => quote! { #[builder(finish_fn)] client: &restson::RestClient }, - }; - - let call_args: Vec = other_args.iter().map(|(id, _)| { - quote! { #id } - }).collect(); + let body_sig = body_fields.iter().map(|(ident, ty, _attrs)| { + quote! { #ident: #ty } + }); let expanded = quote! { #[bon::builder] #vis fn #name( - #client_def, - #(#arg_defs),* - ) -> impl std::future::Future> + '_ { + #[builder(finish_fn)] + client: &restson::RestClient, + #( #[builder(finish_fn)] #path_idents: #path_types, )* + #( #query_sig, )* + #( #body_sig, )* + ) -> impl std::future::Future> + '_ { + let mut path = format!(#path_fmt, #( #path_idents = #path_idents ),*); + let mut query_pairs = Vec::new(); + #( #query_pairs )* + let mut body_map = serde_json::Map::new(); + #( #body_pairs )* + async move { - let result = client.get::<_, serde_json::Value>(#path).await?; - Ok(result) + if body_map.is_empty() { + client.request_with(#method, &path, &query_pairs, &()).await + } else { + client.request_with(#method, &path, &query_pairs, &body_map).await + } } } }; - expanded.into() + TokenStream::from(expanded) } From 10bbee30db3c8ba6dfb6370148bba19c3e189813 Mon Sep 17 00:00:00 2001 From: Jonas Rabenstein Date: Fri, 27 Feb 2026 06:18:44 +0100 Subject: [PATCH 06/15] empty --- macros/src/lib.rs | 149 ++++++++++++---------------------------------- 1 file changed, 38 insertions(+), 111 deletions(-) diff --git a/macros/src/lib.rs b/macros/src/lib.rs index 93fe0cb..841eba8 100644 --- a/macros/src/lib.rs +++ b/macros/src/lib.rs @@ -1,130 +1,57 @@ +// macros/src/lib.rs use proc_macro::TokenStream; use quote::quote; -use syn::{ - parse_macro_input, FnArg, ItemFn, LitStr, Pat, PatType, Type, Attribute, spanned::Spanned, -}; +use syn::{parse_macro_input, ItemFn, FnArg, Pat, Type, Ident, Attribute}; -/// Path args parser for `#[endpoint((x:u128,y:String): "/path/{x}/{y}")]` -struct EndpointPath { - args: Vec<(syn::Ident, syn::Type)>, - path: LitStr, -} - -impl syn::parse::Parse for EndpointPath { - fn parse(input: syn::parse::ParseStream) -> syn::Result { - let content; - syn::parenthesized!(content in input); - - let mut args = Vec::new(); - while !content.is_empty() { - let ident: syn::Ident = content.parse()?; - content.parse::()?; - let ty: syn::Type = content.parse()?; - args.push((ident, ty)); - - if content.peek(syn::Token![,]) { - content.parse::()?; - } - } - - input.parse::()?; - let path: LitStr = input.parse()?; - - Ok(EndpointPath { args, path }) - } +/// Simple argument representation +struct Arg { + attrs: Vec, + ident: Ident, + ty: Type, } #[proc_macro_attribute] -pub fn endpoint(attr: TokenStream, item: TokenStream) -> TokenStream { - let path_args = parse_macro_input!(attr as EndpointPath); - let func = parse_macro_input!(item as ItemFn); +pub fn builder(_attr: TokenStream, item: TokenStream) -> TokenStream { + // Parse the input function + let input = parse_macro_input!(item as ItemFn); - let vis = &func.vis; - let name = &func.sig.ident; - let output = &func.sig.output; + let vis = &input.vis; + let name = &input.sig.ident; + let generics = &input.sig.generics; - // Separate query/body args - let mut query_fields = Vec::new(); - let mut body_fields = Vec::new(); + // Collect arguments + let mut body_args: Vec = Vec::new(); - for arg in &func.sig.inputs { - if let FnArg::Typed(PatType { pat, ty, attrs, .. }) = arg { - let pat_ident = match &**pat { - Pat::Ident(pi) => &pi.ident, - _ => continue, - }; - - if attrs.iter().any(|a| a.path().is_ident("query")) { - query_fields.push((pat_ident.clone(), (*ty).clone(), attrs.clone())); - } else if attrs.iter().any(|a| a.path().is_ident("body")) { - body_fields.push((pat_ident.clone(), (*ty).clone(), attrs.clone())); + for arg in &input.sig.inputs { + if let FnArg::Typed(pat_type) = arg { + if let Pat::Ident(pat_ident) = &*pat_type.pat { + body_args.push(Arg { + attrs: pat_type.attrs.clone(), + ident: pat_ident.ident.clone(), + ty: (*pat_type.ty).clone(), + }); + } else { + panic!("Only simple identifier patterns are supported"); } + } else { + panic!("&self / &mut self not supported"); } } - // Path args - let path_idents: Vec<_> = path_args.args.iter().map(|(i, _)| i).collect(); - let path_types: Vec<_> = path_args.args.iter().map(|(_, t)| t).collect(); - let path_fmt = &path_args.path; - - // Build query serialization - let query_pairs = query_fields.iter().map(|(ident, _, _)| { - quote! { - if let Some(v) = &#ident { - query_pairs.push((stringify!(#ident), v.to_string())); - } - } - }); - - // Build body serialization - let body_pairs = body_fields.iter().map(|(ident, _, _)| { - quote! { - body_map.insert(stringify!(#ident).to_string(), serde_json::to_value(&#ident)?); - } - }); - - // Determine method - let method = if body_fields.is_empty() { quote! { GET } } else { quote! { POST } }; - - // Expand query/body fields for function signature - let query_sig = query_fields.iter().map(|(ident, ty, _attrs)| { - if let Type::Path(tp) = &**ty { // <-- dereference the Box - if tp.path.segments.last().unwrap().ident == "Option" { - quote! { #[builder(default)] #ident: #ty } - } else { - quote! { #ident: #ty } - } - } else { - quote! { #ident: #ty } - } - }); - - let body_sig = body_fields.iter().map(|(ident, ty, _attrs)| { - quote! { #ident: #ty } - }); + // Destructure the arguments for quote repetitions + let arg_idents: Vec<_> = body_args.iter().map(|a| &a.ident).collect(); + let arg_tys: Vec<_> = body_args.iter().map(|a| &a.ty).collect(); + let arg_attrs: Vec<_> = body_args.iter().map(|a| &a.attrs).collect(); + // Generate the builder function let expanded = quote! { #[bon::builder] - #vis fn #name( - #[builder(finish_fn)] - client: &restson::RestClient, - #( #[builder(finish_fn)] #path_idents: #path_types, )* - #( #query_sig, )* - #( #body_sig, )* - ) -> impl std::future::Future> + '_ { - let mut path = format!(#path_fmt, #( #path_idents = #path_idents ),*); - let mut query_pairs = Vec::new(); - #( #query_pairs )* - let mut body_map = serde_json::Map::new(); - #( #body_pairs )* - - async move { - if body_map.is_empty() { - client.request_with(#method, &path, &query_pairs, &()).await - } else { - client.request_with(#method, &path, &query_pairs, &body_map).await - } - } + #vis fn #name #generics ( + #( + #( #arg_attrs )* #arg_idents : #arg_tys + ),* + ) -> impl std::future::Future> { + todo!() } }; From 9ab32a7c85b0dc5cd28811b92c48d3a437141fc9 Mon Sep 17 00:00:00 2001 From: Jonas Rabenstein Date: Fri, 27 Feb 2026 06:24:31 +0100 Subject: [PATCH 07/15] closure like syntax v1 --- macros/src/lib.rs | 190 ++++++++++++++++++++++++++++++++++++---------- 1 file changed, 150 insertions(+), 40 deletions(-) diff --git a/macros/src/lib.rs b/macros/src/lib.rs index 841eba8..5811fbf 100644 --- a/macros/src/lib.rs +++ b/macros/src/lib.rs @@ -1,57 +1,167 @@ -// macros/src/lib.rs use proc_macro::TokenStream; -use quote::quote; -use syn::{parse_macro_input, ItemFn, FnArg, Pat, Type, Ident, Attribute}; - -/// Simple argument representation -struct Arg { - attrs: Vec, - ident: Ident, - ty: Type, -} +use quote::{quote, ToTokens}; +use syn::{ + parse_macro_input, AttributeArgs, FnArg, Ident, ItemFn, Pat, PatIdent, PatType, ReturnType, + Type, Expr, ExprClosure, token::Comma, spanned::Spanned, +}; +/// The procedural macro #[proc_macro_attribute] -pub fn builder(_attr: TokenStream, item: TokenStream) -> TokenStream { +pub fn endpoint(attr: TokenStream, item: TokenStream) -> TokenStream { // Parse the input function - let input = parse_macro_input!(item as ItemFn); + let input_fn = parse_macro_input!(item as ItemFn); - let vis = &input.vis; - let name = &input.sig.ident; - let generics = &input.sig.generics; + // Parse the closure-like attribute: |x: u128, y: String| POST "/some/{x}/{y}" + let closure_expr: ExprClosure = match syn::parse(attr.clone()) { + Ok(c) => c, + Err(e) => return e.to_compile_error().into(), + }; - // Collect arguments - let mut body_args: Vec = Vec::new(); + // Extract path parameters + let mut path_idents = Vec::new(); + let mut path_types = Vec::new(); - for arg in &input.sig.inputs { - if let FnArg::Typed(pat_type) = arg { - if let Pat::Ident(pat_ident) = &*pat_type.pat { - body_args.push(Arg { - attrs: pat_type.attrs.clone(), - ident: pat_ident.ident.clone(), - ty: (*pat_type.ty).clone(), - }); - } else { - panic!("Only simple identifier patterns are supported"); + for fnarg in closure_expr.inputs.iter() { + match fnarg { + FnArg::Typed(PatType { pat, ty, .. }) => { + if let Pat::Ident(PatIdent { ident, .. }) = **pat { + path_idents.push(ident.clone()); + path_types.push(*ty.clone()); + } else { + return syn::Error::new(pat.span(), "Unsupported pattern in path parameters") + .to_compile_error() + .into(); + } + } + _ => { + return syn::Error::new(fnarg.span(), "Expected typed parameter") + .to_compile_error() + .into(); } - } else { - panic!("&self / &mut self not supported"); } } - // Destructure the arguments for quote repetitions - let arg_idents: Vec<_> = body_args.iter().map(|a| &a.ident).collect(); - let arg_tys: Vec<_> = body_args.iter().map(|a| &a.ty).collect(); - let arg_attrs: Vec<_> = body_args.iter().map(|a| &a.attrs).collect(); + // Extract method and path literal from closure body + let (method, path_lit) = match *closure_expr.body { + Expr::Assign(ref assign) => { + return syn::Error::new(assign.span(), "Unexpected assignment in endpoint") + .to_compile_error() + .into(); + } + Expr::Path(_) | Expr::Call(_) | Expr::Lit(_) => { + return syn::Error::new(closure_expr.body.span(), "Expected method + path string") + .to_compile_error() + .into(); + } + Expr::Tuple(ref tup) => { + return syn::Error::new(closure_expr.body.span(), "Unexpected tuple in endpoint") + .to_compile_error() + .into(); + } + Expr::Binary(ref _bin) => { + return syn::Error::new(closure_expr.body.span(), "Unexpected binary in endpoint") + .to_compile_error() + .into(); + } + _ => { + // We will parse method & path using a simple hack: the closure body is `POST "/some/{x}"` etc + let ts = closure_expr.body.to_token_stream().to_string(); + let ts = ts.trim(); + let parts: Vec<&str> = ts.splitn(2, ' ').collect(); + if parts.len() != 2 { + return syn::Error::new(closure_expr.body.span(), "Expected `METHOD \"/path\"`") + .to_compile_error() + .into(); + } + let method = parts[0].trim().to_uppercase(); + let path_lit = syn::LitStr::new(parts[1].trim_matches('"'), closure_expr.body.span()); + (method, path_lit) + } + }; - // Generate the builder function + // Extract original function signature details + let vis = &input_fn.vis; + let orig_name = &input_fn.sig.ident; + let orig_generics = &input_fn.sig.generics; + let orig_inputs = &input_fn.sig.inputs; + let output = match &input_fn.sig.output { + ReturnType::Type(_, ty) => ty, + ReturnType::Default => { + return syn::Error::new(input_fn.sig.output.span(), "Function must have a return type") + .to_compile_error() + .into(); + } + }; + + // Split query vs body params + let mut query_idents = Vec::new(); + let mut query_types = Vec::new(); + let mut body_idents = Vec::new(); + let mut body_types = Vec::new(); + + for arg in orig_inputs.iter() { + match arg { + FnArg::Typed(PatType { pat, ty, attrs, .. }) => { + let is_query = attrs.iter().any(|a| a.path().is_ident("query")); + if let Pat::Ident(PatIdent { ident, .. }) = &**pat { + if is_query { + query_idents.push(ident.clone()); + query_types.push(*ty.clone()); + } else { + body_idents.push(ident.clone()); + body_types.push(*ty.clone()); + } + } + } + _ => {} + } + } + + // Build the transformed function let expanded = quote! { #[bon::builder] - #vis fn #name #generics ( - #( - #( #arg_attrs )* #arg_idents : #arg_tys - ),* - ) -> impl std::future::Future> { - todo!() + #vis async fn #orig_name #orig_generics ( + #( #[builder(finish_fn)] #path_idents: #path_types, )* + client: restson::RestClient, + #( #body_idents: #body_types ),* + ) -> Result<#output, restson::Error> { + // Query struct + #[derive(serde::Serialize)] + struct Query { + #( #query_idents: #query_types, )* + } + let query = Query { #( #query_idents ),* }; + let query = query.to_vec::<(&str, &str)>(); + + // Body struct + #[derive(serde::Serialize)] + struct Body { + #( #body_idents: #body_types, )* + } + let body = Body { #( #body_idents ),* }; + + // RestPath impl for path parameters + impl restson::RestPath<( #( #path_types ),* )> for Body { + fn get_url(&self, #( #path_idents: #path_types ),* ) -> Result { + Ok(format!(#path_lit #(, #path_idents )* )) + } + } + + // Response placeholder + #[derive(serde::de::DeserializeOwned)] + struct Response(Vec); + + // Make the REST call + let response: restson::Response = match #method { + ref m if m == "GET" => client.get_with(body, query).await?, + ref m if m == "POST" => client.post_capture_with(body, query).await?, + _ => panic!("Unsupported method"), + }; + + // Wrap the original todo!(response -> OutputType) + | #( #path_idents ),* | { + todo!(response -> #output) + } ( #( #path_idents ),* ) } }; From f99777bf77f625f978d2c3bc7ea076dd21f76c42 Mon Sep 17 00:00:00 2001 From: Jonas Rabenstein Date: Fri, 27 Feb 2026 06:38:25 +0100 Subject: [PATCH 08/15] closure like syntax v2 --- macros/src/lib.rs | 170 ++++++++++++---------------------------------- 1 file changed, 45 insertions(+), 125 deletions(-) diff --git a/macros/src/lib.rs b/macros/src/lib.rs index 5811fbf..a09a442 100644 --- a/macros/src/lib.rs +++ b/macros/src/lib.rs @@ -1,137 +1,69 @@ use proc_macro::TokenStream; -use quote::{quote, ToTokens}; -use syn::{ - parse_macro_input, AttributeArgs, FnArg, Ident, ItemFn, Pat, PatIdent, PatType, ReturnType, - Type, Expr, ExprClosure, token::Comma, spanned::Spanned, -}; +use quote::quote; +use syn::{parse_macro_input, Expr, ExprClosure, FnArg, ItemFn, Pat, PatIdent, PatType}; -/// The procedural macro #[proc_macro_attribute] pub fn endpoint(attr: TokenStream, item: TokenStream) -> TokenStream { - // Parse the input function let input_fn = parse_macro_input!(item as ItemFn); + let closure_expr = parse_macro_input!(attr as Expr); - // Parse the closure-like attribute: |x: u128, y: String| POST "/some/{x}/{y}" - let closure_expr: ExprClosure = match syn::parse(attr.clone()) { - Ok(c) => c, - Err(e) => return e.to_compile_error().into(), - }; + let fn_name = input_fn.sig.ident.clone(); + let vis = input_fn.vis.clone(); + let generics = input_fn.sig.generics.clone(); - // Extract path parameters - let mut path_idents = Vec::new(); - let mut path_types = Vec::new(); - - for fnarg in closure_expr.inputs.iter() { - match fnarg { - FnArg::Typed(PatType { pat, ty, .. }) => { - if let Pat::Ident(PatIdent { ident, .. }) = **pat { - path_idents.push(ident.clone()); - path_types.push(*ty.clone()); - } else { - return syn::Error::new(pat.span(), "Unsupported pattern in path parameters") - .to_compile_error() - .into(); - } - } - _ => { - return syn::Error::new(fnarg.span(), "Expected typed parameter") - .to_compile_error() - .into(); - } - } - } - - // Extract method and path literal from closure body - let (method, path_lit) = match *closure_expr.body { - Expr::Assign(ref assign) => { - return syn::Error::new(assign.span(), "Unexpected assignment in endpoint") - .to_compile_error() - .into(); - } - Expr::Path(_) | Expr::Call(_) | Expr::Lit(_) => { - return syn::Error::new(closure_expr.body.span(), "Expected method + path string") - .to_compile_error() - .into(); - } - Expr::Tuple(ref tup) => { - return syn::Error::new(closure_expr.body.span(), "Unexpected tuple in endpoint") - .to_compile_error() - .into(); - } - Expr::Binary(ref _bin) => { - return syn::Error::new(closure_expr.body.span(), "Unexpected binary in endpoint") - .to_compile_error() - .into(); - } - _ => { - // We will parse method & path using a simple hack: the closure body is `POST "/some/{x}"` etc - let ts = closure_expr.body.to_token_stream().to_string(); - let ts = ts.trim(); - let parts: Vec<&str> = ts.splitn(2, ' ').collect(); - if parts.len() != 2 { - return syn::Error::new(closure_expr.body.span(), "Expected `METHOD \"/path\"`") - .to_compile_error() - .into(); - } - let method = parts[0].trim().to_uppercase(); - let path_lit = syn::LitStr::new(parts[1].trim_matches('"'), closure_expr.body.span()); - (method, path_lit) - } - }; - - // Extract original function signature details - let vis = &input_fn.vis; - let orig_name = &input_fn.sig.ident; - let orig_generics = &input_fn.sig.generics; - let orig_inputs = &input_fn.sig.inputs; - let output = match &input_fn.sig.output { - ReturnType::Type(_, ty) => ty, - ReturnType::Default => { - return syn::Error::new(input_fn.sig.output.span(), "Function must have a return type") - .to_compile_error() - .into(); - } - }; - - // Split query vs body params + // Collect query and body args let mut query_idents = Vec::new(); let mut query_types = Vec::new(); let mut body_idents = Vec::new(); let mut body_types = Vec::new(); - for arg in orig_inputs.iter() { - match arg { - FnArg::Typed(PatType { pat, ty, attrs, .. }) => { - let is_query = attrs.iter().any(|a| a.path().is_ident("query")); - if let Pat::Ident(PatIdent { ident, .. }) = &**pat { - if is_query { - query_idents.push(ident.clone()); - query_types.push(*ty.clone()); - } else { - body_idents.push(ident.clone()); - body_types.push(*ty.clone()); - } - } + for input in &input_fn.sig.inputs { + if let FnArg::Typed(PatType { pat, ty, attrs, .. }) = input { + let ident = if let Pat::Ident(PatIdent { ident, .. }) = &**pat { + ident.clone() + } else { continue; }; + + if attrs.iter().any(|a| a.path().is_ident("query")) { + query_idents.push(ident); + query_types.push(*ty.clone()); + } else { + body_idents.push(ident); + body_types.push(*ty.clone()); } - _ => {} } } - // Build the transformed function + // Extract path args from closure + let mut path_idents = Vec::new(); + let mut path_types = Vec::new(); + + if let Expr::Closure(ExprClosure { inputs, .. }) = closure_expr { + for input in inputs.iter() { + if let Pat::Type(PatType { pat, ty, .. }) = input { + if let Pat::Ident(PatIdent { ident, .. }) = &**pat { + path_idents.push(ident.clone()); + path_types.push(*ty.clone()); + } + } + } + } + + // Generate the final function let expanded = quote! { #[bon::builder] - #vis async fn #orig_name #orig_generics ( + #vis async fn #fn_name #generics ( #( #[builder(finish_fn)] #path_idents: #path_types, )* - client: restson::RestClient, - #( #body_idents: #body_types ),* - ) -> Result<#output, restson::Error> { + #( #query_idents: #query_types, )* + #( #body_idents: #body_types, )* + ) -> Result<_, restson::Error> { + // Query struct #[derive(serde::Serialize)] struct Query { #( #query_idents: #query_types, )* } let query = Query { #( #query_idents ),* }; - let query = query.to_vec::<(&str, &str)>(); + let query_vec = query.to_vec::<(&str, &str)>(); // Body struct #[derive(serde::Serialize)] @@ -140,27 +72,15 @@ pub fn endpoint(attr: TokenStream, item: TokenStream) -> TokenStream { } let body = Body { #( #body_idents ),* }; - // RestPath impl for path parameters - impl restson::RestPath<( #( #path_types ),* )> for Body { - fn get_url(&self, #( #path_idents: #path_types ),* ) -> Result { - Ok(format!(#path_lit #(, #path_idents )* )) - } - } - - // Response placeholder + // Response #[derive(serde::de::DeserializeOwned)] struct Response(Vec); - // Make the REST call - let response: restson::Response = match #method { - ref m if m == "GET" => client.get_with(body, query).await?, - ref m if m == "POST" => client.post_capture_with(body, query).await?, - _ => panic!("Unsupported method"), - }; + let response: restson::Response = + client.post_capture_with(body, query_vec).await?; - // Wrap the original todo!(response -> OutputType) | #( #path_idents ),* | { - todo!(response -> #output) + todo!(response -> _) } ( #( #path_idents ),* ) } }; From 9a5a5fb9d203fc3b1974a4e10373847cbfbd0afc Mon Sep 17 00:00:00 2001 From: Jonas Rabenstein Date: Fri, 27 Feb 2026 07:13:29 +0100 Subject: [PATCH 09/15] closure like syntax v3 --- macros/src/lib.rs | 175 +++++++++++++++++++++++++++------------------- 1 file changed, 103 insertions(+), 72 deletions(-) diff --git a/macros/src/lib.rs b/macros/src/lib.rs index a09a442..7f199c3 100644 --- a/macros/src/lib.rs +++ b/macros/src/lib.rs @@ -1,89 +1,120 @@ use proc_macro::TokenStream; use quote::quote; -use syn::{parse_macro_input, Expr, ExprClosure, FnArg, ItemFn, Pat, PatIdent, PatType}; +use syn::{ + parse_macro_input, Attribute, FnArg, Ident, ItemFn, Pat, PatIdent, PatType, Type, +}; -#[proc_macro_attribute] -pub fn endpoint(attr: TokenStream, item: TokenStream) -> TokenStream { - let input_fn = parse_macro_input!(item as ItemFn); - let closure_expr = parse_macro_input!(attr as Expr); +/// Represents a function argument we care about +#[derive(Clone)] +struct Arg { + ident: Ident, + ty: Type, + attrs: Vec, +} - let fn_name = input_fn.sig.ident.clone(); - let vis = input_fn.vis.clone(); - let generics = input_fn.sig.generics.clone(); - - // Collect query and body args - let mut query_idents = Vec::new(); - let mut query_types = Vec::new(); - let mut body_idents = Vec::new(); - let mut body_types = Vec::new(); - - for input in &input_fn.sig.inputs { - if let FnArg::Typed(PatType { pat, ty, attrs, .. }) = input { +/// Extract arguments marked as `#[path]` or the rest +fn extract_args<'a, I>(inputs: I, path_only: bool) -> Vec +where + I: IntoIterator, +{ + let mut args = Vec::new(); + for fnarg in inputs { + if let FnArg::Typed(PatType { pat, ty, attrs, .. }) = fnarg { let ident = if let Pat::Ident(PatIdent { ident, .. }) = &**pat { ident.clone() - } else { continue; }; - - if attrs.iter().any(|a| a.path().is_ident("query")) { - query_idents.push(ident); - query_types.push(*ty.clone()); } else { - body_idents.push(ident); - body_types.push(*ty.clone()); + panic!("Only simple identifiers are supported in endpoint arguments"); + }; + + if path_only && !attrs.iter().any(|a| a.path().is_ident("path")) { + continue; } + + args.push(Arg { + ident, + ty: *ty.clone(), + attrs: attrs.clone(), + }); } } + args +} - // Extract path args from closure - let mut path_idents = Vec::new(); - let mut path_types = Vec::new(); +/// Implements #[get("…")] and #[post("…")] +macro_rules! endpoint_macro { + ($method:ident) => { + #[proc_macro_attribute] + pub fn $method(attr: TokenStream, item: TokenStream) -> TokenStream { + let path_lit = parse_macro_input!(attr as syn::LitStr); + let input_fn = parse_macro_input!(item as ItemFn); - if let Expr::Closure(ExprClosure { inputs, .. }) = closure_expr { - for input in inputs.iter() { - if let Pat::Type(PatType { pat, ty, .. }) = input { - if let Pat::Ident(PatIdent { ident, .. }) = &**pat { - path_idents.push(ident.clone()); - path_types.push(*ty.clone()); + let vis = &input_fn.vis; + let fn_name = &input_fn.sig.ident; + let generics = &input_fn.sig.generics; + let inputs = &input_fn.sig.inputs; + let output = &input_fn.sig.output; + + let path_args = extract_args(inputs, true); + let other_args: Vec<_> = extract_args(inputs, false) + .into_iter() + .filter(|a| !path_args.iter().any(|p| p.ident == a.ident)) + .collect(); + + // for builder: path args first + let path_idents: Vec<_> = path_args.iter().map(|a| &a.ident).collect(); + let path_types: Vec<_> = path_args.iter().map(|a| &a.ty).collect(); + + let body_idents: Vec<_> = other_args.iter().map(|a| &a.ident).collect(); + let body_types: Vec<_> = other_args.iter().map(|a| &a.ty).collect(); + + let method_upper = stringify!($method).to_uppercase(); + + let expanded = quote! { + #[bon::builder] + #vis async fn #fn_name #generics ( + #[ builder(finish_fn) ] client: restson::RestClient, + #( #[builder(finish_fn)] #path_idents: #path_types, )* + #( #body_idents: #body_types, )* + ) -> Result<#output, restson::Error> { + // build path + let path = format!(#path_lit, #( #path_idents = #path_idents ),*); + + #[derive(serde::Serialize)] + struct Body { + #( #body_idents: #body_idents, )* + } + + let body = Body { + #( #body_idents, )* + }; + + // for query arguments, if any + #[derive(serde::Serialize)] + struct Query { + #( #body_idents: #body_idents, )* + } + + let query = Query { + #( #body_idents, )* + }; + // placeholder: convert query to vec of pairs + let query_pairs: Vec<(&str, &str)> = Vec::new(); + + let response = match #method_upper { + "GET" => client.get_with(path, query_pairs).await?, + "POST" => client.post_capture_with(body, query_pairs).await?, + _ => unreachable!(), + }; + + + todo!(response) } - } - } - } + }; - // Generate the final function - let expanded = quote! { - #[bon::builder] - #vis async fn #fn_name #generics ( - #( #[builder(finish_fn)] #path_idents: #path_types, )* - #( #query_idents: #query_types, )* - #( #body_idents: #body_types, )* - ) -> Result<_, restson::Error> { - - // Query struct - #[derive(serde::Serialize)] - struct Query { - #( #query_idents: #query_types, )* - } - let query = Query { #( #query_idents ),* }; - let query_vec = query.to_vec::<(&str, &str)>(); - - // Body struct - #[derive(serde::Serialize)] - struct Body { - #( #body_idents: #body_types, )* - } - let body = Body { #( #body_idents ),* }; - - // Response - #[derive(serde::de::DeserializeOwned)] - struct Response(Vec); - - let response: restson::Response = - client.post_capture_with(body, query_vec).await?; - - | #( #path_idents ),* | { - todo!(response -> _) - } ( #( #path_idents ),* ) + expanded.into() } }; - - TokenStream::from(expanded) } + +endpoint_macro!(get); +endpoint_macro!(post); From aaf9781fe8f7f0ed881042adef6519afd598ec90 Mon Sep 17 00:00:00 2001 From: Jonas Rabenstein Date: Fri, 27 Feb 2026 07:26:57 +0100 Subject: [PATCH 10/15] closure like syntax v3 --- macros/src/lib.rs | 141 ++++++++++++++-------------------------------- 1 file changed, 41 insertions(+), 100 deletions(-) diff --git a/macros/src/lib.rs b/macros/src/lib.rs index 7f199c3..995f029 100644 --- a/macros/src/lib.rs +++ b/macros/src/lib.rs @@ -1,120 +1,61 @@ use proc_macro::TokenStream; use quote::quote; -use syn::{ - parse_macro_input, Attribute, FnArg, Ident, ItemFn, Pat, PatIdent, PatType, Type, -}; +use syn::{parse_macro_input, ItemFn, FnArg, Pat, PatType, PatIdent, Type, LitStr}; -/// Represents a function argument we care about -#[derive(Clone)] -struct Arg { - ident: Ident, - ty: Type, - attrs: Vec, -} +use syn::{punctuated::Punctuated, token::Comma}; -/// Extract arguments marked as `#[path]` or the rest -fn extract_args<'a, I>(inputs: I, path_only: bool) -> Vec -where - I: IntoIterator, -{ +fn extract_path_args(inputs: &Punctuated) -> Vec<(syn::Ident, syn::Type)> { let mut args = Vec::new(); - for fnarg in inputs { - if let FnArg::Typed(PatType { pat, ty, attrs, .. }) = fnarg { - let ident = if let Pat::Ident(PatIdent { ident, .. }) = &**pat { - ident.clone() - } else { - panic!("Only simple identifiers are supported in endpoint arguments"); - }; - - if path_only && !attrs.iter().any(|a| a.path().is_ident("path")) { - continue; + for arg in inputs { + if let syn::FnArg::Typed(pat_type) = arg { + if pat_type.attrs.iter().any(|a| a.path().is_ident("path")) { + if let syn::Pat::Ident(pat_ident) = &*pat_type.pat { + args.push((pat_ident.ident.clone(), (*pat_type.ty).clone())); + } } - - args.push(Arg { - ident, - ty: *ty.clone(), - attrs: attrs.clone(), - }); } } args } -/// Implements #[get("…")] and #[post("…")] -macro_rules! endpoint_macro { - ($method:ident) => { - #[proc_macro_attribute] - pub fn $method(attr: TokenStream, item: TokenStream) -> TokenStream { - let path_lit = parse_macro_input!(attr as syn::LitStr); - let input_fn = parse_macro_input!(item as ItemFn); +fn generate_endpoint(attr: TokenStream, item: TokenStream, method: &str) -> TokenStream { + let item_fn = parse_macro_input!(item as ItemFn); + let path_lit = parse_macro_input!(attr as LitStr); - let vis = &input_fn.vis; - let fn_name = &input_fn.sig.ident; - let generics = &input_fn.sig.generics; - let inputs = &input_fn.sig.inputs; - let output = &input_fn.sig.output; + let fn_name = &item_fn.sig.ident; + let vis = &item_fn.vis; + let generics = &item_fn.sig.generics; - let path_args = extract_args(inputs, true); - let other_args: Vec<_> = extract_args(inputs, false) - .into_iter() - .filter(|a| !path_args.iter().any(|p| p.ident == a.ident)) - .collect(); + let path_args = extract_path_args(&item_fn.sig.inputs); + let path_idents: Vec<_> = path_args.iter().map(|(id, _)| id).collect(); + let path_types: Vec<_> = path_args.iter().map(|(_, ty)| ty).collect(); - // for builder: path args first - let path_idents: Vec<_> = path_args.iter().map(|a| &a.ident).collect(); - let path_types: Vec<_> = path_args.iter().map(|a| &a.ty).collect(); + let ret_type = match &item_fn.sig.output { + syn::ReturnType::Default => quote! { () }, + syn::ReturnType::Type(_, ty) => quote! { #ty }, + }; - let body_idents: Vec<_> = other_args.iter().map(|a| &a.ident).collect(); - let body_types: Vec<_> = other_args.iter().map(|a| &a.ty).collect(); + let expanded = quote! { + #[bon::builder] + #vis async fn #fn_name #generics( + #[builder(finish_fn)] client: restson::RestClient, + #( #[builder(finish_fn)] #path_idents: #path_types, )* + ) -> Result<#ret_type, restson::Error> { + let path = format!(#path_lit, #( #path_idents = #path_idents, )* ); - let method_upper = stringify!($method).to_uppercase(); - - let expanded = quote! { - #[bon::builder] - #vis async fn #fn_name #generics ( - #[ builder(finish_fn) ] client: restson::RestClient, - #( #[builder(finish_fn)] #path_idents: #path_types, )* - #( #body_idents: #body_types, )* - ) -> Result<#output, restson::Error> { - // build path - let path = format!(#path_lit, #( #path_idents = #path_idents ),*); - - #[derive(serde::Serialize)] - struct Body { - #( #body_idents: #body_idents, )* - } - - let body = Body { - #( #body_idents, )* - }; - - // for query arguments, if any - #[derive(serde::Serialize)] - struct Query { - #( #body_idents: #body_idents, )* - } - - let query = Query { - #( #body_idents, )* - }; - // placeholder: convert query to vec of pairs - let query_pairs: Vec<(&str, &str)> = Vec::new(); - - let response = match #method_upper { - "GET" => client.get_with(path, query_pairs).await?, - "POST" => client.post_capture_with(body, query_pairs).await?, - _ => unreachable!(), - }; - - - todo!(response) - } - }; - - expanded.into() + todo!("Replace this with client.{} call", #method) } }; + + TokenStream::from(expanded) } -endpoint_macro!(get); -endpoint_macro!(post); +#[proc_macro_attribute] +pub fn get(attr: TokenStream, item: TokenStream) -> TokenStream { + generate_endpoint(attr, item, "get_with") +} + +#[proc_macro_attribute] +pub fn post(attr: TokenStream, item: TokenStream) -> TokenStream { + generate_endpoint(attr, item, "post_capture_with") +} From e69bcfc23d321396be82c6282912e10ac6c43a35 Mon Sep 17 00:00:00 2001 From: Jonas Rabenstein Date: Thu, 5 Mar 2026 01:57:37 +0100 Subject: [PATCH 11/15] working example --- .gitignore | 7 + Cargo.toml | 4 + api/Cargo.toml | 12 ++ api/src/authentication.rs | 127 ++++++++++++ api/src/group.rs | 39 ++++ api/src/lib.rs | 123 ++++++++++++ api/src/profile.rs | 44 +++++ api/src/series.rs | 18 ++ api/src/spond.rs | 242 +++++++++++++++++++++++ api/src/user.rs | 41 ++++ cli/Cargo.toml | 9 +- cli/src/api/mod.rs | 103 ---------- cli/src/authentication.rs | 198 ++++++++----------- cli/src/history.rs | 26 +++ cli/src/main.rs | 398 ++++++++++++++++++++++++++++++++++---- flake.lock | 25 +++ flake.nix | 64 ++++++ macros/src/lib.rs | 98 ++++++++-- 18 files changed, 1308 insertions(+), 270 deletions(-) create mode 100644 .gitignore create mode 100644 Cargo.toml create mode 100644 api/Cargo.toml create mode 100644 api/src/authentication.rs create mode 100644 api/src/group.rs create mode 100644 api/src/lib.rs create mode 100644 api/src/profile.rs create mode 100644 api/src/series.rs create mode 100644 api/src/spond.rs create mode 100644 api/src/user.rs delete mode 100644 cli/src/api/mod.rs create mode 100644 cli/src/history.rs create mode 100644 flake.lock create mode 100644 flake.nix diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..10363bd --- /dev/null +++ b/.gitignore @@ -0,0 +1,7 @@ +* +!.gitignore +!/api/ +!/cli/ +!Cargo.toml +!/*/src/ +!/*/src/**/*.rs diff --git a/Cargo.toml b/Cargo.toml new file mode 100644 index 0000000..67a02f0 --- /dev/null +++ b/Cargo.toml @@ -0,0 +1,4 @@ +[workspace] +resolver = "3" +#members = ["api","cli","schema"] +members = ["api", "cli" , "macros"] diff --git a/api/Cargo.toml b/api/Cargo.toml new file mode 100644 index 0000000..83284c8 --- /dev/null +++ b/api/Cargo.toml @@ -0,0 +1,12 @@ +[package] +name = "spond-api" +version = "0.1.0" +edition = "2024" + +[dependencies] +bon = "3.9.0" +chrono = { version = "0.4.44", features = ["serde"] } +restson = "1.5.0" +serde = { version = "1.0.228", features = ["derive"] } +serde_json = "1.0.149" +thiserror = "2.0.18" diff --git a/api/src/authentication.rs b/api/src/authentication.rs new file mode 100644 index 0000000..c8f5201 --- /dev/null +++ b/api/src/authentication.rs @@ -0,0 +1,127 @@ +use serde::{Deserialize, Serialize}; +use restson::{RestClient, RestPath, Error, Response}; + +#[derive(Debug, Copy, Clone, Serialize)] +struct Email<'a> { + email: &'a str, + password: &'a str, +} + +impl<'a> RestPath<()> for Email<'a> { + fn get_path(_: ()) -> Result { + Ok(String::from("auth2/login")) + } +} + +#[derive(Debug, Copy, Clone, Serialize)] +struct Phone<'a> { + phone: &'a str, + password: &'a str, +} + +impl<'a> RestPath<()> for Phone<'a> { + fn get_path(_: ()) -> Result { + Ok(String::from("auth2/login")) + } +} + +#[derive(Debug, Copy, Clone, Serialize)] +struct Token<'a> { + token: &'a str, +} + +impl<'a> RestPath<()> for Token<'a> { + fn get_path(_: ()) -> Result { + Ok(String::from("auth2/login/refresh")) + } +} + +pub mod token { + use serde::{Serialize, Deserialize}; + use crate::util::DateTime; + use std::ops::Deref; + + #[derive(Debug, Clone, Serialize, Deserialize)] + pub struct Token { + token: String, + } + + impl AsRef for Token { + fn as_ref(&self) -> &str { + &self.token + } + } + + #[derive(Debug, Deserialize, Serialize)] + pub struct WithExpiration { + #[serde(flatten)] + pub token: Token, + #[allow(unused)] + pub expiration: DateTime, + } + + #[derive(Debug, Deserialize)] + #[serde(transparent)] + pub struct Access(WithExpiration); + + impl Deref for Access { + type Target = WithExpiration; + + fn deref(&self) -> &WithExpiration { + &self.0 + } + } + + #[derive(Debug, Deserialize)] + #[serde(transparent)] + pub struct Refresh(WithExpiration); + + impl Deref for Refresh { + type Target = WithExpiration; + fn deref(&self) -> &WithExpiration { + &self.0 + } + } + + #[derive(Debug, Deserialize)] + #[serde(transparent)] + pub struct Password(WithExpiration); + + impl Deref for Password { + type Target = WithExpiration; + fn deref(&self) -> &WithExpiration { + &self.0 + } + } +} + +#[derive(Debug, Deserialize)] +pub struct Tokens { + #[serde(rename = "accessToken")] + pub access: token::Access, + #[serde(rename = "refreshToken")] + pub refresh: token::Refresh, + #[serde(rename = "passwordToken")] + pub password: token::Password, +} + +async fn authenticate(client: &RestClient, request: R) -> Result +where + R: RestPath<()>, + R: Serialize, +{ + let tokens: Response = client.post_capture((), &request).await?; + Ok(tokens.into_inner()) +} + +pub fn email<'a>(client: &'a RestClient, email: &'a str, password: &'a str) -> impl Future> + 'a { + authenticate(client, Email { email, password }) +} + +pub fn phone<'a>(client: &'a RestClient, phone: &'a str, password: &'a str) -> impl Future> + 'a { + authenticate(client, Phone { phone, password }) +} + +pub fn token<'a>(client: &'a RestClient, token: &'a str) -> impl Future> + 'a { + authenticate(client, Token { token }) +} diff --git a/api/src/group.rs b/api/src/group.rs new file mode 100644 index 0000000..22b014b --- /dev/null +++ b/api/src/group.rs @@ -0,0 +1,39 @@ +use super::GroupId as Id; +use super::MemberId; +use restson::{Error, RestPath}; +use serde::Deserialize; + +#[derive(Debug, Deserialize)] +pub struct Group { + pub id: Id, + + #[serde(flatten)] + unknown: serde_json::Value, +} + +impl std::fmt::Display for Group { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + write!( + f, + "{}", + serde_json::to_string_pretty(&self.unknown).unwrap() + ) + } +} + +impl RestPath for Group { + fn get_path(id: Id) -> std::result::Result { + Ok(format!("groups/{id}")) + } +} + +#[derive(Debug, Deserialize)] +pub struct Member { + pub id: MemberId, + + #[serde(flatten)] + pub unknown: serde_json::Value, +} +impl super::util::id::Type for Member { + type Type = super::util::X128; +} diff --git a/api/src/lib.rs b/api/src/lib.rs new file mode 100644 index 0000000..e71fe94 --- /dev/null +++ b/api/src/lib.rs @@ -0,0 +1,123 @@ +use std::collections::{ + HashMap as Map, + //HashSet as Set, +}; + +pub mod util; + +pub mod authentication; + +pub mod profile; +pub use profile::Profile; +pub type ProfileId = util::Id; + +pub mod spond; +pub use spond::Spond; +pub type SpondId = util::Id; + +pub mod series; +pub use series::Series; +pub type SeriesId = util::Id; + +pub mod group; +pub use group::Group; +pub type GroupId = util::Id; +pub type MemberId = util::Id; + +impl>> util::id::Type for T { + type Type = util::X128; +} + +//impl,)> + serde::de::DeserializeOwned + util::id::Type> +// util::Id +//{ +// pub async fn load(&self, client: &restson::RestClient) -> Result { +// Ok(client.get_with::<_, T>((*self,), &[]).await?.into_inner()) +// } +//} + +use serde::{Deserialize, Serialize}; + +#[derive(Default)] +struct Query<'a>(Vec<(&'a str, String)>); + +impl<'a> Query<'a> { + pub fn add(&mut self, key: &'a str, value: impl std::fmt::Display) { + self.0.push((key, value.to_string())); + } + + pub fn maybe_add(&mut self, key: &'a str, value: Option) { + if let Some(value) = value { + self.add(key, value); + } + } + + fn as_slice(&self) -> Vec<(&'a str, &str)> { + self.0.iter().map(|(k, v)| (*k, v.as_str())).collect() + } +} + +#[derive(Serialize)] +pub enum Order { + Ascending, + Descending, +} + +impl Default for Order { + fn default() -> Self { + Self::Ascending + } +} + +impl std::fmt::Display for Order { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + write!(f, "{}", self.as_ref()) + } +} + +impl AsRef for Order { + fn as_ref(&self) -> &str { + match self { + Self::Ascending => "asc", + Self::Descending => "desc", + } + } +} + +impl From for Order { + fn from(ascending: bool) -> Self { + if ascending { + Self::Ascending + } else { + Self::Descending + } + } +} + +#[derive(Debug, Deserialize)] +#[serde(rename_all = "camelCase")] +pub struct DeclineMessage { + pub message: String, + pub profile_id: MemberId, +} + +#[derive(Debug, Deserialize)] +#[serde(rename_all = "camelCase")] +pub struct Responses { + #[serde(default)] + pub accepted_ids: Vec, + #[serde(default)] + pub declined_ids: Vec, + #[serde(default)] + pub waitinglist_ids: Vec, + #[serde(default)] + pub unanswered_ids: Vec, + #[serde(default)] + pub unconfirmed_ids: Vec, + #[serde(default)] + pub participant_ids: Vec, + #[serde(default)] + pub decline_messages: Map, + #[serde(flatten)] + pub unknown: Map, +} diff --git a/api/src/profile.rs b/api/src/profile.rs new file mode 100644 index 0000000..eee352e --- /dev/null +++ b/api/src/profile.rs @@ -0,0 +1,44 @@ +use super::ProfileId as Id; +use restson::{Error, RestClient, RestPath}; +use serde::Deserialize; + +#[derive(Debug, Deserialize)] +pub struct Profile { + pub id: Id, + + #[serde(flatten)] + unknown: serde_json::Value, +} + +impl std::fmt::Display for Profile { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + write!( + f, + "{}", + serde_json::to_string_pretty(&self.unknown).unwrap() + ) + } +} + +impl RestPath for Profile { + fn get_path(id: Id) -> std::result::Result { + Ok(format!("profile/{id}")) + } +} + +impl RestPath<()> for Profile { + fn get_path(_: ()) -> std::result::Result { + Ok("profile".to_string()) + } +} + +pub async fn identity(client: &RestClient) -> Result { + Ok(client.get_with::<_, Profile>((), &[]).await?.into_inner()) +} + +pub async fn with_id(client: &RestClient, id: Id) -> Result { + Ok(client + .get_with::<_, Profile>(id, &[]) + .await? + .into_inner()) +} diff --git a/api/src/series.rs b/api/src/series.rs new file mode 100644 index 0000000..da4c130 --- /dev/null +++ b/api/src/series.rs @@ -0,0 +1,18 @@ +use restson::{Error, RestPath}; +use serde::Deserialize; + +use super::SeriesId as Id; + +#[derive(Debug, Deserialize)] +pub struct Series { + pub id: Id, + + #[serde(flatten)] + pub unknown: serde_json::Value, +} + +impl RestPath for Series { + fn get_path(id: Id) -> std::result::Result { + Ok(format!("series/{id}")) + } +} diff --git a/api/src/spond.rs b/api/src/spond.rs new file mode 100644 index 0000000..f77e3fd --- /dev/null +++ b/api/src/spond.rs @@ -0,0 +1,242 @@ +use super::{ + MemberId, Order, ProfileId, Query, Responses, SeriesId, SpondId as Id, + util::{DateTime, Timestamp, Visibility}, +}; +use restson::{Error, RestClient, RestPath}; +use serde::Deserialize; +use std::collections::HashMap; +use std::future::Future; + +#[derive(Debug, Deserialize)] +#[serde(rename_all = "camelCase")] +pub struct Group { + #[serde(flatten)] + pub unknown: HashMap, +} + +#[derive(Debug, Deserialize)] +#[serde(rename_all = "camelCase")] +pub struct Recipients { + pub group: HashMap, + pub guardians: std::vec::Vec, + pub profiles: std::vec::Vec, +} + +#[derive(Debug, Deserialize)] +#[serde(rename_all = "camelCase")] +pub struct Comment { + pub id: crate::util::Id, + pub children: std::vec::Vec, + pub from_profile_id: ProfileId, + pub reactions: HashMap>, + pub text: String, + pub timestamp: DateTime, +} + +impl crate::util::id::Type for Comment { + type Type = crate::util::X128; +} + +#[derive(Debug, Deserialize)] +#[serde(rename_all = "camelCase")] +pub struct Spond { + pub id: Id, + pub heading: String, + pub series_id: Option, + pub responses: Responses, + pub updated: Timestamp, + pub recipients: Recipients, + pub hidden: bool, + pub comments: Vec, + pub auto_accept: bool, + pub start_timestamp: DateTime, + pub end_timestamp: DateTime, + pub creator_id: ProfileId, + pub visibility: Visibility, + pub behalf_of_ids: Vec, + + #[serde(flatten)] + pub unknown: HashMap, +} + +#[bon::bon] +impl Spond { + #[builder] + pub fn response( + &self, + #[builder(start_fn)] + member: MemberId, + #[builder(finish_fn)] + client: &RestClient, + #[builder(default = true)] + accepted: bool, + ) -> impl Future> { + response(self.id) + .member(member) + .accepted(accepted) + .call(client) + } + + #[builder] + pub fn accept(&self, + #[builder(start_fn)] + member: MemberId, + #[builder(finish_fn)] + client: &RestClient, + ) -> impl Future> { + self.response(member) + .accepted(true) + .call(client) + } + + #[builder] + pub fn decline(&self, + #[builder(start_fn)] + member: MemberId, + #[builder(finish_fn)] + client: &RestClient, + ) -> impl Future> { + self.response(member) + .accepted(false) + .call(client) + } +} + +impl std::fmt::Display for Spond { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + write!( + f, + "{}", + serde_json::to_string_pretty(&self.unknown).unwrap() + ) + } +} + +#[derive(Debug, serde::Deserialize)] +struct Sponds(Vec); + +impl RestPath<()> for Sponds { + fn get_path(_: ()) -> std::result::Result { + Ok(String::from("sponds")) + } +} + +impl RestPath for Spond { + fn get_path(id: Id) -> std::result::Result { + Ok(format!("sponds/{id}")) + } +} + +impl RestPath<()> for Spond { + fn get_path(_: ()) -> std::result::Result { + Ok("sponds".to_string()) + } +} + +#[bon::builder] +pub async fn spond( + #[builder(finish_fn)] client: &RestClient, + #[builder(finish_fn)] id: Id, + + // query flags + include_comments: Option, + add_profile_info: Option, +) -> Result { + let mut q = Query::default(); + q.maybe_add("includeComments", include_comments); + q.maybe_add("addProfileInfo", add_profile_info); + + Ok(client + .get_with::<_, Spond>(id, &q.as_slice()) + .await? + .into_inner()) +} + +#[bon::builder] +pub async fn search( + #[builder(finish_fn)] client: &RestClient, + + // query flags + include_comments: Option, + comments: Option, + hidden: Option, + add_profile_info: Option, + scheduled: Option, + #[builder(default, into)] order: Order, + #[builder(default = 20)] max: usize, + #[builder(into)] min_end_timestamp: Option, + #[builder(into)] max_end_timestamp: Option, + #[builder(into)] min_start_timestamp: Option, + #[builder(into)] max_start_timestamp: Option, + prev_id: Option, + series_id: Option, +) -> Result, Error> { + let mut q = Query::default(); + q.maybe_add("seriesId", series_id); + q.maybe_add("includeComments", include_comments); + q.maybe_add("comments", comments); + q.maybe_add("addProfileInfo", add_profile_info); + q.maybe_add("scheduled", scheduled); + q.maybe_add("hidden", hidden); + q.maybe_add("minEndTimestamp", min_end_timestamp); + q.maybe_add("maxEndTimestamp", max_end_timestamp); + q.maybe_add("minStartTimestamp", min_start_timestamp); + q.maybe_add("maxStartTimestamp", max_start_timestamp); + q.maybe_add("prevId", prev_id); + q.add("order", order); + q.add("max", max); + + Ok(client + .get_with::<_, Sponds>((), &q.as_slice()) + .await? + .into_inner() + .0) +} + +#[bon::builder] +pub fn decline( + #[builder(start_fn)] spond: Id, + #[builder(finish_fn)] client: &RestClient, + member: MemberId, +) -> impl std::future::Future> { + response(spond) + .member(member) + .accepted(false) + .call(client) +} + +#[bon::builder] +pub fn accept( + #[builder(start_fn)] spond: Id, + #[builder(finish_fn)] client: &RestClient, + member: MemberId, +) -> impl std::future::Future> { + response(spond) + .member(member) + .accepted(true) + .call(client) +} + +#[bon::builder] +pub async fn response( + #[builder(start_fn)] spond: Id, + #[builder(finish_fn)] client: &RestClient, + member: MemberId, + accepted: bool, +) -> Result { + #[derive(Debug, serde::Serialize)] + struct Request { + accepted: bool, + } + + impl RestPath<(Id, MemberId)> for Request { + fn get_path(args: (Id, MemberId)) -> std::result::Result { + let (spond, member) = args; + Ok(format!("sponds/{spond}/responses/{member}")) + } + } + + let request = Request{accepted}; + let response: restson::Response = client.put_capture((spond, member), &request).await?; + Ok(response.into_inner()) +} diff --git a/api/src/user.rs b/api/src/user.rs new file mode 100644 index 0000000..c41e186 --- /dev/null +++ b/api/src/user.rs @@ -0,0 +1,41 @@ +use serde::Deserialize; +use restson::{RestClient, RestPath, Error}; + +use super::{ + UserId as Id, +}; + +#[derive(Debug, Deserialize)] +pub struct User { + pub id: Id, + + #[serde(flatten)] + unknown: serde_json::Value, +} + +impl std::fmt::Display for User { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + write!(f, "{}", serde_json::to_string_pretty(&self.unknown).unwrap()) + } +} + +impl RestPath<()> for User { + fn get_path(_: ()) -> std::result::Result { + Ok(format!("user")) + } +} + +impl RestPath<(Id, )> for User { + fn get_path(args: (Id, )) -> std::result::Result { + let (id, ) = args; + Ok(format!("user/{id}")) + } +} + +pub async fn identity(client: &RestClient) -> Result { + Ok(client.get_with::<_, User>((), &[]).await?.into_inner()) +} + +pub async fn with_id(client: &RestClient, id: Id) -> Result { + Ok(client.get_with::<_, User>((id, ), &[]).await?.into_inner()) +} diff --git a/cli/Cargo.toml b/cli/Cargo.toml index 389ce79..4797ca4 100644 --- a/cli/Cargo.toml +++ b/cli/Cargo.toml @@ -9,11 +9,18 @@ bon = "3.9.0" chrono = { version = "0.4.44", features = ["serde"] } clap = { version = "4.5.60", features = ["cargo", "derive", "env" ] } env_logger = "0.11.9" +futures = "0.3.32" http = "1.4.0" +log = "0.4.29" +rand = "0.10.0" restson = "1.5.0" rpassword = "7.4.0" serde = { version = "1.0.228", features = ["derive"] } serde_json = "1.0.149" -spond-macros = { version = "0.1.0", path = "../macros" } +serde_qs = "1.0.0" +spond-api = { version = "0.1.0", path = "../api" } +thiserror = "2.0.18" +#spond-macros = { version = "0.1.0", path = "../macros" } tokio = { version = "1.49.0", features = ["macros", "rt-multi-thread"] } url = "2.5.8" +xdg = "3.0.0" diff --git a/cli/src/api/mod.rs b/cli/src/api/mod.rs deleted file mode 100644 index be81c07..0000000 --- a/cli/src/api/mod.rs +++ /dev/null @@ -1,103 +0,0 @@ -//use bon::Builder; -use chrono::{DateTime,Utc}; -use serde::{Serialize, Deserialize}; -//use restson::{RestClient, RestPath, Error}; -// -#[derive(Serialize)] -pub enum Order { - Ascending, - Descending, -} - -impl AsRef for Order { - fn as_ref(&self) -> &str { - match self { - Self::Ascending => "asc", - Self::Descending => "desc", - } - } -} - -impl From for Order { - fn from(ascending: bool) -> Self { - if ascending { - Self::Ascending - } else { - Self::Descending - } - } -} - -#[derive(Debug, Deserialize)] -pub struct Spond { - id: String, - -} -// -//#[bon::builder] -//#[builder(on(bool, default=false))] -//fn sponds( -// comments: bool, -// hidden: bool, -// add_profile_info: bool, -// scheduled=bool, -// #[builder(into)] -// order=Order, -// #[builder(default = 20)] -// max=usize, -// min_end_timestamp=Option>, -// max_end_timestamp=Option>, -//) -> Get<(), Vec> { - -//crate::get!(sponds( -// comments: bool, -// hidden: bool, -// add_profile_info: bool, -// scheduled, -// #[builder(into, default=Order::Ascending)] order: Order, -// #[builder(default=20)]max: usize, -// min_end_timestamp: Option>, -// max_end_timestamp: Option>, -// ), -// () => "sponds" -> Vec); - -#[spond_macros::endpoint((id:u128):"/spond/{id:032X}/info", (eid:u128, uid:u128): "/spond/{eid:032X}/response/{uid:032X}")] -pub async fn sponds(result: serde_json::Value, - #[query] comments: Option, - #[query] hidden: Option, - #[body] min_end_timestamp: Option>, -) -> serde_json::Value { - result -} - - -/* -crate::post!(post( - comments: bool, - hidden: bool, - add_profile_info: bool, - scheduled: bool, - #[builder(into)] order: Order, - #[builder(default=20)]max: usize, - ) - min_end_timestamp: Option>, - max_end_timestamp: Option>, - () => "sponds" -> Vec); -*/ -//impl Search { -// with_comments( -//#[bon::builder] -//#[builder(on(bool, default=false))] -//fn sponds( -// comments: bool, -// hidden: bool, -// add_profile_info: bool, -// scheduled=bool, -// #[builder(into)] -// order=Order, -// #[builder(default = 20)] -// max=usize, -// min_end_timestamp=Option>, -// max_end_timestamp=Option>, -//) -> Search { -//} diff --git a/cli/src/authentication.rs b/cli/src/authentication.rs index 2f0c42b..49a6378 100644 --- a/cli/src/authentication.rs +++ b/cli/src/authentication.rs @@ -1,11 +1,7 @@ use clap::{Args, ArgGroup}; -use restson::{RestClient, RestPath, Response}; +use restson::RestClient; use anyhow::{Result, Error}; -use serde::{ - ser::{Serialize, Serializer, SerializeMap}, - Deserialize, -}; -use chrono::{DateTime, Utc}; +use std::str::{FromStr}; #[derive(Args, Debug)] #[command(group( @@ -14,10 +10,10 @@ use chrono::{DateTime, Utc}; ))] pub struct Authentication { #[arg(long)] - access: Option, + access: Option, #[arg(long)] - refresh: Option, + refresh: Option, #[arg(long)] email: Option, @@ -26,13 +22,18 @@ pub struct Authentication { phone: Option, } +fn bearer(mut client: RestClient, token: &str) -> Result { + client.set_header("Authorization", &format!("Bearer {}", token))?; + Ok(client) +} + impl Authentication { - pub async fn apply(self, client: RestClient) -> Result { - let client = match (self.access, self.refresh, self.email, self.phone) { - (Some(v), None, None, None) => v.apply(client)?, - (None, Some(v), None, None) => Tokens::authenticate(client, v).await?, - (None, None, Some(v), None) => Tokens::authenticate(client, v).await?, - (None, None, None, Some(v)) => Tokens::authenticate(client, v).await?, + pub async fn apply(&self, client: RestClient) -> Result { + let client = match (self.access.as_ref(), self.refresh.as_ref(), self.email.as_ref(), self.phone.as_ref()) { + (Some(ref v), None, None, None) => v.apply(client)?, + (None, Some(ref v), None, None) => v.apply(client).await?, + (None, None, Some(ref v), None) => v.apply(client).await?, + (None, None, None, Some(ref v)) => v.apply(client).await?, (None, None, None, None) => client, (a, b, c, d) => anyhow::bail!("invalid authentication: {} + {} + {} + {}", a.is_some(), b.is_some(), c.is_some(), d.is_some()), }; @@ -40,126 +41,87 @@ impl Authentication { } } -mod identifier { - #[derive(Debug, Clone)] - pub struct Email; - #[derive(Debug, Clone)] - pub struct Phone; -} - -trait Identifier: Clone { - const NAME: &'static str; - type Value: std::str::FromStr + std::fmt::Debug + Clone + serde::Serialize; - type Error: std::error::Error + Send + Sync + 'static; -} - -impl Identifier for identifier::Email { - const NAME: &'static str = "email"; - type Value = String; - type Error = ::Err; -} - -impl Identifier for identifier::Phone { - const NAME: &'static str = "phone"; - type Value = String; - type Error = ::Err; -} - #[derive(Debug, Clone)] -struct WithPassword { - value: I::Value, +struct WithPassword { + value: String, password: String, } - -impl Serialize for WithPassword { - fn serialize(&self, serializer: S) -> Result - { - let mut map = serializer.serialize_map(Some(2))?; - map.serialize_entry(I::NAME, &self.value)?; - map.serialize_entry("password", &self.password)?; - map.end() - } -} - -impl RestPath<()> for WithPassword { - fn get_path(_: ()) -> std::result::Result { - Ok(String::from("auth2/login")) - } -} - -type Email = WithPassword; -type Phone = WithPassword; - -impl std::str::FromStr for WithPassword { - type Err= Error; +impl FromStr for WithPassword { + type Err = Error; fn from_str(s: &str) -> Result { let password = match std::env::var("SPOND_PASSWORD") { Ok(password) => password, Err(_) => rpassword::prompt_password("Password: ")?, }; - let value = I::Value::from_str(s)?; + let value = String::from_str(s)?; Ok(Self { value, password }) } } -#[derive(Debug, Deserialize)] -struct Tokens { - #[serde(rename = "accessToken")] - access: TokenWithExpiration, - #[serde(rename = "refreshToken")] - refresh: TokenWithExpiration, -} - -impl Tokens { - async fn authenticate>(client: RestClient, request: R) -> Result { - let tokens: Response = client.post_capture((), &request).await?; - tokens.into_inner().apply(client) - } - - fn apply(self, client: RestClient) -> Result { - println!("refresh: {self:?}"); - self.access.token.apply(client) - } - -} - -#[derive(Debug, Deserialize)] -struct TokenWithExpiration { - token: Token, - #[allow(unused)] - expiration: DateTime -} - -#[derive(Debug, Clone, Deserialize)] -struct Token(String); - -impl Serialize for Token { - fn serialize(&self, serializer: S) -> Result - { - let mut map = serializer.serialize_map(Some(1))?; - map.serialize_entry("token", &self.0)?; - map.end() +#[derive(Debug, Clone)] +struct Email(WithPassword); +impl Email { + async fn apply(&self, client: RestClient) -> Result { + let tokens = spond_api::authentication::email(&client, &self.0.value, &self.0.password).await?; + bearer(client, tokens.access.token.as_ref()) } } - -impl Token { - fn apply(self, mut client: RestClient) -> Result { - client.set_header("Authorization", &format!("Bearer {}", self.0))?; - Ok(client) - } -} - -impl RestPath<()> for Token { - fn get_path(_: ()) -> std::result::Result { - Ok(String::from("auth2/login/refresh")) - } -} - -impl std::str::FromStr for Token { - type Err = std::convert::Infallible; +impl FromStr for Email { + type Err= ::Err; fn from_str(s: &str) -> Result { - Ok(Self(s.to_string())) + Ok(Self(WithPassword::from_str(s)?)) + } +} + +#[derive(Debug, Clone)] +struct Phone(WithPassword); +impl Phone { + async fn apply(&self, client: RestClient) -> Result { + let tokens = spond_api::authentication::phone(&client, &self.0.value, &self.0.password).await?; + bearer(client, tokens.access.token.as_ref()) + } +} +impl FromStr for Phone { + type Err= ::Err; + + fn from_str(s: &str) -> Result { + Ok(Self(WithPassword::from_str(s)?)) + } +} + +#[derive(Debug, Clone)] +struct Access(String); + +impl Access { + fn apply(&self, client: RestClient) -> Result { + bearer(client, &self.0) + } +} + +impl FromStr for Access { + type Err = std::convert::Infallible; // parsing a String never fails + + fn from_str(s: &str) -> Result { + Ok(Access(s.to_string())) + } +} + +#[derive(Debug, Clone)] +struct Refresh(String); + +impl Refresh { + async fn apply(&self, client: RestClient) -> Result { + let tokens = spond_api::authentication::token(&client, &self.0).await?; + bearer(client, tokens.access.token.as_ref()) + } +} + +impl FromStr for Refresh { + type Err = std::convert::Infallible; // parsing a String never fails + + fn from_str(s: &str) -> Result { + Ok(Refresh(s.to_string())) } } diff --git a/cli/src/history.rs b/cli/src/history.rs new file mode 100644 index 0000000..73e5888 --- /dev/null +++ b/cli/src/history.rs @@ -0,0 +1,26 @@ +use std::fd::{File, OpenOptions}; +use std::io::{BufReader, BufWriter, Read, Write}; +use xdg::BaseDirectories; + +pub struct History(File); + +impl History { + pub fn open(serie: spond_api::SeriesId) -> std::io::Result { + let xdg_dirs = BaseDirectories::with_prefix(env!("CARGO_PKG_NAME")); + let path = xdg_dirs.place_state_file(format!("{}.bin", serie))?; + + let file = OpenOptions::new() + .create(true) + .append(true) + .read(true) + .open(&path)?; + + Ok(Self(file)) + } + + pub fn append(&mut self, selected: usize, ids: I) -> io::Result<()> + where + I: IntoIterator, + I::Item: Into, + I::IntoIter: ExactSizeIterator, +} diff --git a/cli/src/main.rs b/cli/src/main.rs index f964c60..2471d48 100644 --- a/cli/src/main.rs +++ b/cli/src/main.rs @@ -2,11 +2,10 @@ use clap::Parser; use restson::RestClient; use anyhow::Result; use url::Url; +use spond_api as api; +use xdg::BaseDirectories as xdg; mod authentication; -mod api; - -mod request; #[derive(Parser, Debug)] #[command(author, version, about)] @@ -14,27 +13,176 @@ struct Cli { #[command(flatten)] authentication: authentication::Authentication, + #[arg(long, default_value_t)] + seed: Seed, + + #[arg(long)] + vip: Option>, + + #[arg(long)] + series: Option, + + #[arg(long)] + heading: Option, + #[arg(long, default_value = "https://api.spond.com/")] base: Url, } impl Cli { - pub async fn client(self) -> Result { + pub async fn client(&self) -> Result { let base = self.base.join("/core/v1/")?; let client = RestClient::new(base.as_str())?; Ok(self.authentication.apply(client).await?) } } -#[derive(Debug, serde::Deserialize)] -struct Spond(serde_json::Value); +#[derive(Debug, Clone, Copy)] +struct Seed(u64); -#[derive(Debug, serde::Deserialize)] -struct Sponds(Vec); +impl Default for Seed { + fn default() -> Self { + use rand::{rng, RngExt}; + Self(rng().random()) + } +} -impl restson::RestPath<()> for Sponds { - fn get_path(_: ()) -> std::result::Result { - Ok(String::from("sponds")) +impl std::str::FromStr for Seed { + type Err = ::Err; + + fn from_str(s: &str) -> std::result::Result { + u64::from_str_radix(s, 16).map(Seed) + } +} + +impl> From for Seed { + fn from(seed: T) -> Self { + Self(seed.into()) + } +} + +impl std::fmt::Display for Seed { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + write!(f, "{:016X}", self.0) + } +} + +impl Seed { + pub fn shuffle<'a, T, F, W>(&self, input: &'a [T], weight: F) -> Result> + where + F: Fn(T) -> W, + W: Into, + T: Copy + { + use rand::{SeedableRng, rngs::StdRng}; + let len = input.len(); + + let sample = rand::seq::index::sample_weighted( + &mut StdRng::seed_from_u64(self.0), + len, + |idx| weight(input[idx]), + len, + )?; + + log::debug!("sample: {:?}", sample); + Ok(sample.into_iter().map(move |idx| input[idx]).collect()) + } +} + + +#[derive(Debug)] +struct Weights(std::collections::HashMap); + +use std::hash::Hash; + +impl Default for Weights +where + Id: Eq + Hash + Copy, +{ + fn default() -> Self { + Self(std::collections::HashMap::default()) + } +} + +impl Weights +where + Id: Eq + Hash + Copy, +{ + fn path(serie: api::SeriesId) -> Result { + let dirs = xdg::with_prefix(env!("CARGO_PKG_NAME")); + Ok(dirs.place_state_file(format!("{serie}.json"))?) + } + + pub fn update(&mut self, keep: &[Id]) -> &mut Self { + // remove keys not in keep + self.0.retain(|key, _| keep.contains(key)); + + // adjust weights + for &key in keep { + let val = self.0.entry(key).or_insert(0); + *val = val.saturating_add(1); + } + + self + } + + pub fn weight(&self, index: impl Into) -> f64 { + let extra = self.0.get(&index.into()).copied().unwrap_or(0); + let sum = 1f64 + (extra as f64); + if sum.is_infinite() { f64::MAX } else { sum } + } +} + +impl Weights +where + Id: Eq + Hash + Copy + serde::de::DeserializeOwned +{ + pub fn load(serie: api::SeriesId) -> Result { + let path = Self::path(serie)?; + log::debug!("load {path:?}"); + let file = std::fs::OpenOptions::new() + .read(true) + .open(path)?; + + let data: std::collections::HashMap = serde_json::from_reader(file)?; + Ok(Self(data)) + } +} + + +impl Weights +where + Id: Eq + Hash + Copy + serde::Serialize +{ + pub fn store(&self, serie: api::SeriesId) -> Result<()> { + use std::fs::{File, rename}; + use std::io::{BufWriter, Write}; + + + let path = Self::path(serie)?; + log::debug!("store {path:?}"); + let tmp = path.with_extension("json.tmp"); + + // create temporary file + let file = File::create(&tmp)?; + let mut writer = BufWriter::new(file); + + // write data to temporary file + serde_json::to_writer_pretty(&mut writer, &self.0)?; + + // flush write buffer + writer.flush()?; + + // sync to disc + writer.get_ref().sync_all()?; + + // close file + drop(writer); + + // atomic replace old file + rename(&tmp, &path)?; + + Ok(()) } } @@ -42,32 +190,212 @@ impl restson::RestPath<()> for Sponds { async fn main() -> Result<()> { env_logger::init(); - let client = Cli::parse().client().await?; - - // https://api.spond.com/core/v1/sponds?includeComments=true&includeHidden=false&addProfileInfo=true&scheduled=true&order=asc&max=20&prevId=F94829E35A9B4A48A042646C8B658B01&minStartTimestamp=2026-04-11T09:45:00Z&minEndTimestamp=2026-02-26T23:00:00.001Z - if false { - let query = [ - ("includeComments", "true"), - ("includeHidden", "false"), - ("addProfileInfo", "true"), - ("scheduled", "true"), - ("order", "asc"), - ("max", "20"), - ]; - - for spond in client.get_with::<_, Sponds>((), &query).await?.into_inner().0 { - println!("{spond:?}"); - } + let cli = Cli::parse(); + let seed = cli.seed; + let series = cli.series.map(api::SeriesId::new); + let heading = cli.heading.as_ref(); + let vip: Vec = if let Some(ref vip) = cli.vip { + vip.into_iter().map(|id| api::MemberId::new(*id)).collect() } else { - let request = api::sponds() - .comments(true) - .hidden(false) - .add_profile_info(false) - .scheduled(true) - ; - for spond in request.call(&client).await? { - println!("{spond:?}"); + [ + 0xEB07B45E45E6449386E70A7411816B6Fu128, + 0xD05F8574AC544C8DB1A7DC5B6347AA49u128, + ].map(|x| api::MemberId::new(x.into())).into() + }; + let client = cli.client().await?; + let client = &client; + + log::info!("seed: {seed}"); + if let Some(series) = series { + log::info!("series: {series}"); + } + if let Some(heading) = heading { + log::info!("heading: {heading}"); + } + + if true { + let now = chrono::Utc::now(); + let sponds = api::spond::search() + .include_comments(true) + .order(api::Order::Ascending) + .max(1000) + .min_start_timestamp(now) + .max_end_timestamp(now + chrono::Duration::weeks(1)) + .call(client).await?; + + for spond in sponds.iter() + .filter(|spond| { + let result = series.is_none_or(|series| spond.series_id.is_some_and(|remote| remote == series)) + && heading.is_none_or(|heading| spond.heading == *heading); + log::trace!("{}: {:?} == {:?} => {:?}", spond.heading, spond.series_id, series, result); + result + }) + { + log::debug!("{:?}", spond.responses); + + let spond = &spond; + let decline = |id: &api::MemberId| { + log::info!("remove {0}", *id); + spond.decline(*id).call(client) + }; + let accept = |id: &api::MemberId| { + log::info!("accept {0}", *id); + spond.accept(*id).call(client) + }; + + let mut weights = spond.series_id.and_then(|series| Weights::load(series).ok()).unwrap_or_else(Weights::default); + log::info!("{weights:?}"); + + let (vip, interested) = { + let mut r = (Vec::new(), Vec::new()); + for id in spond.responses.accepted_ids.iter() + .chain(spond.responses.waitinglist_ids.iter()) { + (if vip.contains(id) { &mut r.0 } else { &mut r.1 }).push(*id); + } + (r.0, seed.shuffle(&r.1, |idx| weights.weight(idx))?) + }; + + // remove all registered participants + let results = futures::future::join_all(interested.iter().map(|id|decline(id))).await; + log::debug!("{results:?}"); + + // register them in order + let mut responses = None; + for id in interested.iter() { + responses = Some(accept(id).await?); + } + + if let Some(responses) = responses { + log::debug!("{responses:?}"); + + let reorder = |mut responses: api::Responses| async move { + // someone might have been registered right now + let mut extra = Vec::new(); + loop { + log::debug!("vip: {vip:?}"); + log::debug!("interested: {interested:?}"); + log::debug!("extra: {extra:?}"); + let reorder = responses.accepted_ids.iter() + .chain(responses.waitinglist_ids.iter()) + .filter(|id| !(vip.contains(*id) || interested.contains(*id) || extra.contains(*id))) + .cloned() + .collect::>(); + if reorder.is_empty() { + let update = interested.iter() + .filter(|id| responses.waitinglist_ids.contains(id)) + .cloned() + .collect::>(); + break Ok::, anyhow::Error>(update); + } + let futures = futures::future::join_all(reorder.iter().map(|id|decline(id))).await; + log::debug!("{futures:?}"); + + for id in reorder.into_iter() { + responses = accept(&id).await?; + extra.push(id); + } + + tokio::time::sleep(tokio::time::Duration::from_secs(10)).await; + } + }; + + let update = reorder(responses).await?; + weights.update(&update); + } else { + weights = Weights::default(); + }; + + log::debug!("{weights:?}"); + + if let Some(series) = spond.series_id { + let _ = weights.store(series)?; + } } + + + //for member in spond.responses.accepted_ids.iter() + // .chain(spond.responses.waitinglist_ids.iter()) { + // let result = map.insert(member, 1); + // println!("{:?}: {:?}", member, result); + //} + //println!("{:?}", map); + //println!("{:?}", &spond.responses); + //let response = spond.response(member) + // .accepted(false) + // .call(&client) + // .await?; + //println!("{:?}", &response); + } else if true { + let profile = api::profile::identity(&client).await; + if let Ok(profile) = profile { + println!("profile: {:?}: {profile}", &profile.id); + } + } else if false { + //let query = [ + // ("includeSponds", "true"), + //]; + //let series = client.get_with::<_, Series>((0xCCBE049C31DA4FB691158E3FBC2DFBC8u128,), &query).await?.into_inner().0; + let now = api::util::DateTime::default(); + let sponds = api::spond::search() + .include_comments(true) + .order(api::Order::Ascending) + .max(100) + .series_id(api::SeriesId::new(0x9333BDD4135E48BEAE88F1C3006A5FC0u128.into())) + .min_end_timestamp(now) + .min_start_timestamp(now) + .call(&client).await?; + for spond in sponds.iter() { + println!("{spond:?}"); + //let spond = api::spond().call(&client, api::SpondId::new(0xF131CD46F80A42B9909D8E7F4018D8E1u128.into())).await?; + //println!("{spond:?}"); + } + //} else if true { + // + //#[derive(Debug, serde::Deserialize, serde::Serialize)] + //struct Spond(serde_json::Value); + // + //#[derive(Debug, serde::Deserialize, serde::Serialize)] + //struct Sponds(Vec); + // + //impl restson::RestPath<()> for Sponds { + // fn get_path(_: ()) -> std::result::Result { + // Ok(String::from("sponds")) + // } + //} + // let now = &DateTime::default(); + // log::info!("{now:?} | {}", now.to_string()); + // let query = [ + // ("includeComments", "true"), + // //("includeHidden", "true"), + // ("addProfileInfo", "true"), + // ("hidden", "true"), + // ("scheduled", "true"), + // ("order", "asc"), + // ("max", "20"), + // ("heading", "Schwimmtraining Donnerstag"), + // ("seriesId", "CCBE049C31DA4FB691158E3FBC2DFBC8u128"), + // ("minStartTimestamp", &now.to_string()), + // ]; + // + // for spond in client.get_with::<_, api::spond::Sponds>((), &query).await?.into_inner().0 { + // //match spond.0 { + // // serde_json::Value::Object(map) => { + // // println!("{:?}", map); + // // }, + // // _ => {}, + // //}; + // println!("{}", serde_json::to_string_pretty(&spond).unwrap()); + // } + //} else { + // let request = api::sponds() + // .add_profile_info(false) + // .comments(true) + // .hidden(false) + // .scheduled(true) + // ; + // for spond in request.call(&client).await? { + // println!("{spond:?}"); + // } } Ok(()) diff --git a/flake.lock b/flake.lock new file mode 100644 index 0000000..dc8a583 --- /dev/null +++ b/flake.lock @@ -0,0 +1,25 @@ +{ + "nodes": { + "nixpkgs": { + "locked": { + "lastModified": 1772615108, + "narHash": "sha256-lC0KbklwgeSqS+sTkaYpnSYr/HDeVMzYUZqV/dT31Lo=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "0c39f3b5a9a234421d4ad43ab9c7cf64840172d0", + "type": "github" + }, + "original": { + "id": "nixpkgs", + "type": "indirect" + } + }, + "root": { + "inputs": { + "nixpkgs": "nixpkgs" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/flake.nix b/flake.nix new file mode 100644 index 0000000..4130f54 --- /dev/null +++ b/flake.nix @@ -0,0 +1,64 @@ +{ + outputs = { nixpkgs, ... }: let + spond = { rustPlatform, rustfmt, clippy, pkg-config, openssl, ... }: rustPlatform.buildRustPackage { + pname = "spond"; + version = "0.0.0"; + + src = ./.; + cargoLock.lockFile = ./Cargo.lock; + nativeBuildInputs = [ + pkg-config + ]; + propagatedBuildInputs = [ + openssl.dev + ]; + }; + + allpkgs = system: pkgs: pkgs.extend (_: _: nixpkgs.lib.attrsets.filterAttrs (name: _: name != "default") (packages system pkgs)); + + packages = system: pkgs': let + pkgs = allpkgs system pkgs'; + in { + default = pkgs.spond; + spond = pkgs.callPackage spond {}; + }; + + devShells = system: pkgs': let + pkgs = allpkgs system pkgs'; + in builtins.mapAttrs (devShell pkgs) (packages system pkgs'); + + devShell = pkgs: name: pkg: pkgs.mkShell { + buildInputs = with pkgs; [ + cargo + cargo-bloat + cargo-machete + cargo-workspaces + cargo-unused-features + cargo-udeps + cargo-audit + cargo-diet + cargo-duplicates + cargo-expand + cargo-flamegraph + clippy + lldb + gdb + + (python3.withPackages (py: [ py.pyyaml ])) + + rustc + rustfmt + openssl.dev + ] ++ pkg.buildInputs; + + nativeBuildInputs = pkg.nativeBuildInputs; + + shellHook = '' + printf 'Dev shell for %s ready!\n' '${pkg.name}' + ''; + }; + in { + packages = builtins.mapAttrs packages nixpkgs.legacyPackages; + devShells = builtins.mapAttrs devShells nixpkgs.legacyPackages; + }; +} diff --git a/macros/src/lib.rs b/macros/src/lib.rs index 995f029..4296daa 100644 --- a/macros/src/lib.rs +++ b/macros/src/lib.rs @@ -1,21 +1,67 @@ use proc_macro::TokenStream; use quote::quote; -use syn::{parse_macro_input, ItemFn, FnArg, Pat, PatType, PatIdent, Type, LitStr}; +use syn::{parse_macro_input, ItemFn, LitStr}; use syn::{punctuated::Punctuated, token::Comma}; -fn extract_path_args(inputs: &Punctuated) -> Vec<(syn::Ident, syn::Type)> { - let mut args = Vec::new(); - for arg in inputs { +#[derive(Copy, Clone, PartialEq)] +enum Class { + Query, + Path, + Body, +} + +impl Class { + fn classify(pat_type: &syn::PatType, default: Self) -> Self { + let mut result = None; + for a in pat_type.attrs.iter() { + let class = if a.path().is_ident("path") { + Some(Self::Path) + } else if a.path().is_ident("query") { + Some(Self::Query) + } else if a.path().is_ident("body") { + Some(Self::Body) + } else { + None + }; + if class.is_some() { + if result.is_some() && result != class { + panic!("can only have one class!"); + } + result = class; + } + } + + if let Some(result) = result { + result + } else { + default + } + } +} + +fn extract_args(inputs: &Punctuated, class: Class, default: Class) -> (Vec, Vec, Vec) { + let mut idents = Vec::new(); + let mut types = Vec::new(); + let mut attrs = Vec::new(); + for arg in inputs.iter().skip(1) { if let syn::FnArg::Typed(pat_type) = arg { - if pat_type.attrs.iter().any(|a| a.path().is_ident("path")) { + //if pat_type.attrs.iter().any(|a| a.path().is_ident(path)) { + if Class::classify(&pat_type, default) == class { if let syn::Pat::Ident(pat_ident) = &*pat_type.pat { - args.push((pat_ident.ident.clone(), (*pat_type.ty).clone())); + idents.push(pat_ident.ident.clone()); + types.push((*pat_type.ty).clone()); + let meta = pat_type.attrs.iter() + .filter(|a| !["path", "query", "body"].iter().any(|p| a.path().is_ident(p))); + let meta = quote! { + #( #meta )* + }; + attrs.push(meta); } } } } - args + (idents, types, attrs) } fn generate_endpoint(attr: TokenStream, item: TokenStream, method: &str) -> TokenStream { @@ -26,24 +72,50 @@ fn generate_endpoint(attr: TokenStream, item: TokenStream, method: &str) -> Toke let vis = &item_fn.vis; let generics = &item_fn.sig.generics; - let path_args = extract_path_args(&item_fn.sig.inputs); - let path_idents: Vec<_> = path_args.iter().map(|(id, _)| id).collect(); - let path_types: Vec<_> = path_args.iter().map(|(_, ty)| ty).collect(); + let default = Class::Body; + let (path_idents, path_types, path_attrs) = extract_args(&item_fn.sig.inputs, Class::Path, default); + let (query_idents, query_types, query_attrs) = extract_args(&item_fn.sig.inputs, Class::Query, default); + let (body_idents, body_types, body_attrs) = extract_args(&item_fn.sig.inputs, Class::Body, default); let ret_type = match &item_fn.sig.output { syn::ReturnType::Default => quote! { () }, syn::ReturnType::Type(_, ty) => quote! { #ty }, }; + let queries = query_idents.len(); let expanded = quote! { #[bon::builder] #vis async fn #fn_name #generics( - #[builder(finish_fn)] client: restson::RestClient, - #( #[builder(finish_fn)] #path_idents: #path_types, )* + #[builder(finish_fn)] client: &restson::RestClient, + #( #[builder(finish_fn)] #path_attrs #path_idents: #path_types, )* + #( #query_attrs #query_idents: #query_types, )* + #( #body_attrs #body_idents: #body_types, )* ) -> Result<#ret_type, restson::Error> { let path = format!(#path_lit, #( #path_idents = #path_idents, )* ); - todo!("Replace this with client.{} call", #method) + let mut query = Vec::with_capacity(#queries); + + + + #[derive(serde::Serialize)] + #[serde(rename_all = "camelCase")] + struct Q { + #( + #query_attrs #query_idents: #query_types, + )* + } + let q = Q { #( #query_idents, )* }; + let s = serde_qs::to_string(&q).expect("serde_qs serialization"); + for pair in s.split('&') { + let mut kv = pair.splitn(2, '='); + match (kv.next(), kv.next()) { + (Some(k), Some(v)) => query.push((k, v)), + (Some(k), None) => query.push((k, "")), + _ => panic!("should never happen!"), + } + } + + todo!("client.{}({path}, {query:?})", #method) } }; From b09e8eafbbad9055f6887e4a5d86c1bacf0b0529 Mon Sep 17 00:00:00 2001 From: Jonas Rabenstein Date: Thu, 5 Mar 2026 02:05:32 +0100 Subject: [PATCH 12/15] working --- Cargo.lock | 2004 ++++++++++++++++++++++++++++++ api/src/authentication.rs | 21 +- api/src/lib.rs | 7 +- api/src/profile.rs | 5 +- api/src/spond.rs | 60 +- api/src/util/chrono/datetime.rs | 33 + api/src/util/chrono/mod.rs | 5 + api/src/util/chrono/timestamp.rs | 51 + api/src/util/id.rs | 114 ++ api/src/util/mod.rs | 11 + api/src/util/visibility.rs | 36 + api/src/util/x128.rs | 84 ++ cli/Cargo.toml | 3 +- cli/src/authentication.rs | 39 +- cli/src/main.rs | 303 ++--- macros/src/lib.rs | 5 +- 16 files changed, 2527 insertions(+), 254 deletions(-) create mode 100644 Cargo.lock create mode 100644 api/src/util/chrono/datetime.rs create mode 100644 api/src/util/chrono/mod.rs create mode 100644 api/src/util/chrono/timestamp.rs create mode 100644 api/src/util/id.rs create mode 100644 api/src/util/mod.rs create mode 100644 api/src/util/visibility.rs create mode 100644 api/src/util/x128.rs diff --git a/Cargo.lock b/Cargo.lock new file mode 100644 index 0000000..9ea0a82 --- /dev/null +++ b/Cargo.lock @@ -0,0 +1,2004 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +version = 4 + +[[package]] +name = "aho-corasick" +version = "1.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ddd31a130427c27518df266943a5308ed92d4b226cc639f5a8f1002816174301" +dependencies = [ + "memchr", +] + +[[package]] +name = "android_system_properties" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "819e7219dbd41043ac279b19830f2efc897156490d7fd6ea916720117ee66311" +dependencies = [ + "libc", +] + +[[package]] +name = "anstream" +version = "0.6.21" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "43d5b281e737544384e969a5ccad3f1cdd24b48086a0fc1b2a5262a26b8f4f4a" +dependencies = [ + "anstyle", + "anstyle-parse", + "anstyle-query", + "anstyle-wincon", + "colorchoice", + "is_terminal_polyfill", + "utf8parse", +] + +[[package]] +name = "anstyle" +version = "1.0.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5192cca8006f1fd4f7237516f40fa183bb07f8fbdfedaa0036de5ea9b0b45e78" + +[[package]] +name = "anstyle-parse" +version = "0.2.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4e7644824f0aa2c7b9384579234ef10eb7efb6a0deb83f9630a49594dd9c15c2" +dependencies = [ + "utf8parse", +] + +[[package]] +name = "anstyle-query" +version = "1.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "40c48f72fd53cd289104fc64099abca73db4166ad86ea0b4341abe65af83dadc" +dependencies = [ + "windows-sys 0.61.2", +] + +[[package]] +name = "anstyle-wincon" +version = "3.0.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "291e6a250ff86cd4a820112fb8898808a366d8f9f58ce16d1f538353ad55747d" +dependencies = [ + "anstyle", + "once_cell_polyfill", + "windows-sys 0.61.2", +] + +[[package]] +name = "anyhow" +version = "1.0.102" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7f202df86484c868dbad7eaa557ef785d5c66295e41b460ef922eca0723b842c" + +[[package]] +name = "autocfg" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c08606f8c3cbf4ce6ec8e28fb0014a2c086708fe954eaa885384a6165172e7e8" + +[[package]] +name = "base64" +version = "0.13.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9e1b586273c5702936fe7b7d6896644d8be71e6314cfe09d3167c95f712589e8" + +[[package]] +name = "bitflags" +version = "2.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "843867be96c8daad0d758b57df9392b6d8d271134fce549de6ce169ff98a92af" + +[[package]] +name = "bon" +version = "3.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2d13a61f2963b88eef9c1be03df65d42f6996dfeac1054870d950fcf66686f83" +dependencies = [ + "bon-macros", + "rustversion", +] + +[[package]] +name = "bon-macros" +version = "3.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d314cc62af2b6b0c65780555abb4d02a03dd3b799cd42419044f0c38d99738c0" +dependencies = [ + "darling", + "ident_case", + "prettyplease", + "proc-macro2", + "quote", + "rustversion", + "syn", +] + +[[package]] +name = "bumpalo" +version = "3.20.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5d20789868f4b01b2f2caec9f5c4e0213b41e3e5702a50157d699ae31ced2fcb" + +[[package]] +name = "bytes" +version = "1.11.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1e748733b7cbc798e1434b6ac524f0c1ff2ab456fe201501e6497c8417a4fc33" + +[[package]] +name = "cc" +version = "1.2.56" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "aebf35691d1bfb0ac386a69bac2fde4dd276fb618cf8bf4f5318fe285e821bb2" +dependencies = [ + "find-msvc-tools", + "shlex", +] + +[[package]] +name = "cfg-if" +version = "1.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9330f8b2ff13f34540b44e946ef35111825727b38d33286ef986142615121801" + +[[package]] +name = "chacha20" +version = "0.10.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6f8d983286843e49675a4b7a2d174efe136dc93a18d69130dd18198a6c167601" +dependencies = [ + "cfg-if", + "cpufeatures", + "rand_core", +] + +[[package]] +name = "chrono" +version = "0.4.44" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c673075a2e0e5f4a1dde27ce9dee1ea4558c7ffe648f576438a20ca1d2acc4b0" +dependencies = [ + "iana-time-zone", + "js-sys", + "num-traits", + "serde", + "wasm-bindgen", + "windows-link", +] + +[[package]] +name = "clap" +version = "4.5.60" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2797f34da339ce31042b27d23607e051786132987f595b02ba4f6a6dffb7030a" +dependencies = [ + "clap_builder", + "clap_derive", +] + +[[package]] +name = "clap_builder" +version = "4.5.60" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "24a241312cea5059b13574bb9b3861cabf758b879c15190b37b6d6fd63ab6876" +dependencies = [ + "anstream", + "anstyle", + "clap_lex", + "strsim", +] + +[[package]] +name = "clap_derive" +version = "4.5.55" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a92793da1a46a5f2a02a6f4c46c6496b28c43638adea8306fcb0caa1634f24e5" +dependencies = [ + "heck", + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "clap_lex" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3a822ea5bc7590f9d40f1ba12c0dc3c2760f3482c6984db1573ad11031420831" + +[[package]] +name = "colorchoice" +version = "1.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b05b61dc5112cbb17e4b6cd61790d9845d13888356391624cbe7e41efeac1e75" + +[[package]] +name = "core-foundation" +version = "0.10.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b2a6cd9ae233e7f62ba4e9353e81a88df7fc8a5987b8d445b4d90c879bd156f6" +dependencies = [ + "core-foundation-sys", + "libc", +] + +[[package]] +name = "core-foundation-sys" +version = "0.8.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "773648b94d0e5d620f64f280777445740e61fe701025087ec8b57f45c791888b" + +[[package]] +name = "cpufeatures" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8b2a41393f66f16b0823bb79094d54ac5fbd34ab292ddafb9a0456ac9f87d201" +dependencies = [ + "libc", +] + +[[package]] +name = "darling" +version = "0.23.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "25ae13da2f202d56bd7f91c25fba009e7717a1e4a1cc98a76d844b65ae912e9d" +dependencies = [ + "darling_core", + "darling_macro", +] + +[[package]] +name = "darling_core" +version = "0.23.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9865a50f7c335f53564bb694ef660825eb8610e0a53d3e11bf1b0d3df31e03b0" +dependencies = [ + "ident_case", + "proc-macro2", + "quote", + "strsim", + "syn", +] + +[[package]] +name = "darling_macro" +version = "0.23.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ac3984ec7bd6cfa798e62b4a642426a5be0e68f9401cfc2a01e3fa9ea2fcdb8d" +dependencies = [ + "darling_core", + "quote", + "syn", +] + +[[package]] +name = "displaydoc" +version = "0.2.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "97369cbbc041bc366949bc74d34658d6cda5621039731c6310521892a3a20ae0" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "env_filter" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7a1c3cc8e57274ec99de65301228b537f1e4eedc1b8e0f9411c6caac8ae7308f" +dependencies = [ + "log", + "regex", +] + +[[package]] +name = "env_logger" +version = "0.11.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b2daee4ea451f429a58296525ddf28b45a3b64f1acf6587e2067437bb11e218d" +dependencies = [ + "anstream", + "anstyle", + "env_filter", + "jiff", + "log", +] + +[[package]] +name = "equivalent" +version = "1.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "877a4ace8713b0bcf2a4e7eec82529c029f1d0619886d18145fea96c3ffe5c0f" + +[[package]] +name = "errno" +version = "0.3.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "39cab71617ae0d63f51a36d69f866391735b51691dbda63cf6f96d042b63efeb" +dependencies = [ + "libc", + "windows-sys 0.61.2", +] + +[[package]] +name = "fastrand" +version = "2.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "37909eebbb50d72f9059c3b6d82c0463f2ff062c9e95845c43a6c9c0355411be" + +[[package]] +name = "find-msvc-tools" +version = "0.1.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5baebc0774151f905a1a2cc41989300b1e6fbb29aff0ceffa1064fdd3088d582" + +[[package]] +name = "fnv" +version = "1.0.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1" + +[[package]] +name = "foldhash" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d9c4f5dac5e15c24eb999c26181a6ca40b39fe946cbe4c263c7209467bc83af2" + +[[package]] +name = "foreign-types" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f6f339eb8adc052cd2ca78910fda869aefa38d22d5cb648e6485e4d3fc06f3b1" +dependencies = [ + "foreign-types-shared", +] + +[[package]] +name = "foreign-types-shared" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "00b0228411908ca8685dba7fc2cdd70ec9990a6e753e89b6ac91a84c40fbaf4b" + +[[package]] +name = "form_urlencoded" +version = "1.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cb4cb245038516f5f85277875cdaa4f7d2c9a0fa0468de06ed190163b1581fcf" +dependencies = [ + "percent-encoding", +] + +[[package]] +name = "futures" +version = "0.3.32" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8b147ee9d1f6d097cef9ce628cd2ee62288d963e16fb287bd9286455b241382d" +dependencies = [ + "futures-channel", + "futures-core", + "futures-executor", + "futures-io", + "futures-sink", + "futures-task", + "futures-util", +] + +[[package]] +name = "futures-channel" +version = "0.3.32" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "07bbe89c50d7a535e539b8c17bc0b49bdb77747034daa8087407d655f3f7cc1d" +dependencies = [ + "futures-core", + "futures-sink", +] + +[[package]] +name = "futures-core" +version = "0.3.32" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7e3450815272ef58cec6d564423f6e755e25379b217b0bc688e295ba24df6b1d" + +[[package]] +name = "futures-executor" +version = "0.3.32" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "baf29c38818342a3b26b5b923639e7b1f4a61fc5e76102d4b1981c6dc7a7579d" +dependencies = [ + "futures-core", + "futures-task", + "futures-util", +] + +[[package]] +name = "futures-io" +version = "0.3.32" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cecba35d7ad927e23624b22ad55235f2239cfa44fd10428eecbeba6d6a717718" + +[[package]] +name = "futures-macro" +version = "0.3.32" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e835b70203e41293343137df5c0664546da5745f82ec9b84d40be8336958447b" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "futures-sink" +version = "0.3.32" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c39754e157331b013978ec91992bde1ac089843443c49cbc7f46150b0fad0893" + +[[package]] +name = "futures-task" +version = "0.3.32" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "037711b3d59c33004d3856fbdc83b99d4ff37a24768fa1be9ce3538a1cde4393" + +[[package]] +name = "futures-util" +version = "0.3.32" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "389ca41296e6190b48053de0321d02a77f32f8a5d2461dd38762c0593805c6d6" +dependencies = [ + "futures-channel", + "futures-core", + "futures-io", + "futures-macro", + "futures-sink", + "futures-task", + "memchr", + "pin-project-lite", + "slab", +] + +[[package]] +name = "getrandom" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "139ef39800118c7683f2fd3c98c1b23c09ae076556b435f8e9064ae108aaeeec" +dependencies = [ + "cfg-if", + "libc", + "r-efi", + "rand_core", + "wasip2", + "wasip3", +] + +[[package]] +name = "h2" +version = "0.3.27" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0beca50380b1fc32983fc1cb4587bfa4bb9e78fc259aad4a0032d2080309222d" +dependencies = [ + "bytes", + "fnv", + "futures-core", + "futures-sink", + "futures-util", + "http 0.2.12", + "indexmap", + "slab", + "tokio", + "tokio-util", + "tracing", +] + +[[package]] +name = "hashbrown" +version = "0.15.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9229cfe53dfd69f0609a49f65461bd93001ea1ef889cd5529dd176593f5338a1" +dependencies = [ + "foldhash", +] + +[[package]] +name = "hashbrown" +version = "0.16.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "841d1cc9bed7f9236f321df977030373f4a4163ae1a7dbfe1a51a2c1a51d9100" + +[[package]] +name = "heck" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2304e00983f87ffb38b55b444b5e3b60a884b5d30c0fca7d82fe33449bbe55ea" + +[[package]] +name = "http" +version = "0.2.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "601cbb57e577e2f5ef5be8e7b83f0f63994f25aa94d673e54a92d5c516d101f1" +dependencies = [ + "bytes", + "fnv", + "itoa", +] + +[[package]] +name = "http" +version = "1.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e3ba2a386d7f85a81f119ad7498ebe444d2e22c2af0b86b069416ace48b3311a" +dependencies = [ + "bytes", + "itoa", +] + +[[package]] +name = "http-body" +version = "0.4.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7ceab25649e9960c0311ea418d17bee82c0dcec1bd053b5f9a66e265a693bed2" +dependencies = [ + "bytes", + "http 0.2.12", + "pin-project-lite", +] + +[[package]] +name = "httparse" +version = "1.10.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6dbf3de79e51f3d586ab4cb9d5c3e2c14aa28ed23d180cf89b4df0454a69cc87" + +[[package]] +name = "httpdate" +version = "1.0.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "df3b46402a9d5adb4c86a0cf463f42e19994e3ee891101b1841f30a545cb49a9" + +[[package]] +name = "hyper" +version = "0.14.32" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "41dfc780fdec9373c01bae43289ea34c972e40ee3c9f6b3c8801a35f35586ce7" +dependencies = [ + "bytes", + "futures-channel", + "futures-core", + "futures-util", + "h2", + "http 0.2.12", + "http-body", + "httparse", + "httpdate", + "itoa", + "pin-project-lite", + "socket2 0.5.10", + "tokio", + "tower-service", + "tracing", + "want", +] + +[[package]] +name = "hyper-tls" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d6183ddfa99b85da61a140bea0efc93fdf56ceaa041b37d553518030827f9905" +dependencies = [ + "bytes", + "hyper", + "native-tls", + "tokio", + "tokio-native-tls", +] + +[[package]] +name = "iana-time-zone" +version = "0.1.65" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e31bc9ad994ba00e440a8aa5c9ef0ec67d5cb5e5cb0cc7f8b744a35b389cc470" +dependencies = [ + "android_system_properties", + "core-foundation-sys", + "iana-time-zone-haiku", + "js-sys", + "log", + "wasm-bindgen", + "windows-core", +] + +[[package]] +name = "iana-time-zone-haiku" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f31827a206f56af32e590ba56d5d2d085f558508192593743f16b2306495269f" +dependencies = [ + "cc", +] + +[[package]] +name = "icu_collections" +version = "2.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4c6b649701667bbe825c3b7e6388cb521c23d88644678e83c0c4d0a621a34b43" +dependencies = [ + "displaydoc", + "potential_utf", + "yoke", + "zerofrom", + "zerovec", +] + +[[package]] +name = "icu_locale_core" +version = "2.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "edba7861004dd3714265b4db54a3c390e880ab658fec5f7db895fae2046b5bb6" +dependencies = [ + "displaydoc", + "litemap", + "tinystr", + "writeable", + "zerovec", +] + +[[package]] +name = "icu_normalizer" +version = "2.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5f6c8828b67bf8908d82127b2054ea1b4427ff0230ee9141c54251934ab1b599" +dependencies = [ + "icu_collections", + "icu_normalizer_data", + "icu_properties", + "icu_provider", + "smallvec", + "zerovec", +] + +[[package]] +name = "icu_normalizer_data" +version = "2.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7aedcccd01fc5fe81e6b489c15b247b8b0690feb23304303a9e560f37efc560a" + +[[package]] +name = "icu_properties" +version = "2.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "020bfc02fe870ec3a66d93e677ccca0562506e5872c650f893269e08615d74ec" +dependencies = [ + "icu_collections", + "icu_locale_core", + "icu_properties_data", + "icu_provider", + "zerotrie", + "zerovec", +] + +[[package]] +name = "icu_properties_data" +version = "2.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "616c294cf8d725c6afcd8f55abc17c56464ef6211f9ed59cccffe534129c77af" + +[[package]] +name = "icu_provider" +version = "2.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "85962cf0ce02e1e0a629cc34e7ca3e373ce20dda4c4d7294bbd0bf1fdb59e614" +dependencies = [ + "displaydoc", + "icu_locale_core", + "writeable", + "yoke", + "zerofrom", + "zerotrie", + "zerovec", +] + +[[package]] +name = "id-arena" +version = "2.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3d3067d79b975e8844ca9eb072e16b31c3c1c36928edf9c6789548c524d0d954" + +[[package]] +name = "ident_case" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b9e0384b61958566e926dc50660321d12159025e767c18e043daf26b70104c39" + +[[package]] +name = "idna" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3b0875f23caa03898994f6ddc501886a45c7d3d62d04d2d90788d47be1b1e4de" +dependencies = [ + "idna_adapter", + "smallvec", + "utf8_iter", +] + +[[package]] +name = "idna_adapter" +version = "1.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3acae9609540aa318d1bc588455225fb2085b9ed0c4f6bd0d9d5bcd86f1a0344" +dependencies = [ + "icu_normalizer", + "icu_properties", +] + +[[package]] +name = "indexmap" +version = "2.13.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7714e70437a7dc3ac8eb7e6f8df75fd8eb422675fc7678aff7364301092b1017" +dependencies = [ + "equivalent", + "hashbrown 0.16.1", + "serde", + "serde_core", +] + +[[package]] +name = "is_terminal_polyfill" +version = "1.70.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a6cb138bb79a146c1bd460005623e142ef0181e3d0219cb493e02f7d08a35695" + +[[package]] +name = "itoa" +version = "1.0.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "92ecc6618181def0457392ccd0ee51198e065e016d1d527a7ac1b6dc7c1f09d2" + +[[package]] +name = "jiff" +version = "0.2.21" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b3e3d65f018c6ae946ab16e80944b97096ed73c35b221d1c478a6c81d8f57940" +dependencies = [ + "jiff-static", + "log", + "portable-atomic", + "portable-atomic-util", + "serde_core", +] + +[[package]] +name = "jiff-static" +version = "0.2.21" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a17c2b211d863c7fde02cbea8a3c1a439b98e109286554f2860bdded7ff83818" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "js-sys" +version = "0.3.90" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "14dc6f6450b3f6d4ed5b16327f38fed626d375a886159ca555bd7822c0c3a5a6" +dependencies = [ + "once_cell", + "wasm-bindgen", +] + +[[package]] +name = "leb128fmt" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "09edd9e8b54e49e587e4f6295a7d29c3ea94d469cb40ab8ca70b288248a81db2" + +[[package]] +name = "libc" +version = "0.2.182" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6800badb6cb2082ffd7b6a67e6125bb39f18782f793520caee8cb8846be06112" + +[[package]] +name = "linux-raw-sys" +version = "0.12.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "32a66949e030da00e8c7d4434b251670a91556f4144941d37452769c25d58a53" + +[[package]] +name = "litemap" +version = "0.8.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6373607a59f0be73a39b6fe456b8192fcc3585f602af20751600e974dd455e77" + +[[package]] +name = "log" +version = "0.4.29" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5e5032e24019045c762d3c0f28f5b6b8bbf38563a65908389bf7978758920897" + +[[package]] +name = "memchr" +version = "2.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f8ca58f447f06ed17d5fc4043ce1b10dd205e060fb3ce5b979b8ed8e59ff3f79" + +[[package]] +name = "mio" +version = "1.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a69bcab0ad47271a0234d9422b131806bf3968021e5dc9328caf2d4cd58557fc" +dependencies = [ + "libc", + "wasi", + "windows-sys 0.61.2", +] + +[[package]] +name = "native-tls" +version = "0.2.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "465500e14ea162429d264d44189adc38b199b62b1c21eea9f69e4b73cb03bbf2" +dependencies = [ + "libc", + "log", + "openssl", + "openssl-probe", + "openssl-sys", + "schannel", + "security-framework", + "security-framework-sys", + "tempfile", +] + +[[package]] +name = "num-traits" +version = "0.2.19" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "071dfc062690e90b734c0b2273ce72ad0ffa95f0c74596bc250dcfd960262841" +dependencies = [ + "autocfg", +] + +[[package]] +name = "once_cell" +version = "1.21.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "42f5e15c9953c5e4ccceeb2e7382a716482c34515315f7b03532b8b4e8393d2d" + +[[package]] +name = "once_cell_polyfill" +version = "1.70.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "384b8ab6d37215f3c5301a95a4accb5d64aa607f1fcb26a11b5303878451b4fe" + +[[package]] +name = "openssl" +version = "0.10.75" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "08838db121398ad17ab8531ce9de97b244589089e290a384c900cb9ff7434328" +dependencies = [ + "bitflags", + "cfg-if", + "foreign-types", + "libc", + "once_cell", + "openssl-macros", + "openssl-sys", +] + +[[package]] +name = "openssl-macros" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a948666b637a0f465e8564c73e89d4dde00d72d4d473cc972f390fc3dcee7d9c" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "openssl-probe" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7c87def4c32ab89d880effc9e097653c8da5d6ef28e6b539d313baaacfbafcbe" + +[[package]] +name = "openssl-sys" +version = "0.9.111" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "82cab2d520aa75e3c58898289429321eb788c3106963d0dc886ec7a5f4adc321" +dependencies = [ + "cc", + "libc", + "pkg-config", + "vcpkg", +] + +[[package]] +name = "percent-encoding" +version = "2.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9b4f627cb1b25917193a259e49bdad08f671f8d9708acfd5fe0a8c1455d87220" + +[[package]] +name = "pin-project-lite" +version = "0.2.16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3b3cff922bd51709b605d9ead9aa71031d81447142d828eb4a6eba76fe619f9b" + +[[package]] +name = "pkg-config" +version = "0.3.32" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7edddbd0b52d732b21ad9a5fab5c704c14cd949e5e9a1ec5929a24fded1b904c" + +[[package]] +name = "portable-atomic" +version = "1.13.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c33a9471896f1c69cecef8d20cbe2f7accd12527ce60845ff44c153bb2a21b49" + +[[package]] +name = "portable-atomic-util" +version = "0.2.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7a9db96d7fa8782dd8c15ce32ffe8680bbd1e978a43bf51a34d39483540495f5" +dependencies = [ + "portable-atomic", +] + +[[package]] +name = "potential_utf" +version = "0.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b73949432f5e2a09657003c25bca5e19a0e9c84f8058ca374f49e0ebe605af77" +dependencies = [ + "zerovec", +] + +[[package]] +name = "prettyplease" +version = "0.2.37" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "479ca8adacdd7ce8f1fb39ce9ecccbfe93a3f1344b3d0d97f20bc0196208f62b" +dependencies = [ + "proc-macro2", + "syn", +] + +[[package]] +name = "proc-macro2" +version = "1.0.106" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8fd00f0bb2e90d81d1044c2b32617f68fcb9fa3bb7640c23e9c748e53fb30934" +dependencies = [ + "unicode-ident", +] + +[[package]] +name = "quote" +version = "1.0.44" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "21b2ebcf727b7760c461f091f9f0f539b77b8e87f2fd88131e7f1b433b3cece4" +dependencies = [ + "proc-macro2", +] + +[[package]] +name = "r-efi" +version = "5.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "69cdb34c158ceb288df11e18b4bd39de994f6657d83847bdffdbd7f346754b0f" + +[[package]] +name = "rand" +version = "0.10.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bc266eb313df6c5c09c1c7b1fbe2510961e5bcd3add930c1e31f7ed9da0feff8" +dependencies = [ + "chacha20", + "getrandom", + "rand_core", +] + +[[package]] +name = "rand_core" +version = "0.10.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0c8d0fd677905edcbeedbf2edb6494d676f0e98d54d5cf9bda0b061cb8fb8aba" + +[[package]] +name = "regex" +version = "1.12.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e10754a14b9137dd7b1e3e5b0493cc9171fdd105e0ab477f51b72e7f3ac0e276" +dependencies = [ + "aho-corasick", + "memchr", + "regex-automata", + "regex-syntax", +] + +[[package]] +name = "regex-automata" +version = "0.4.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6e1dd4122fc1595e8162618945476892eefca7b88c52820e74af6262213cae8f" +dependencies = [ + "aho-corasick", + "memchr", + "regex-syntax", +] + +[[package]] +name = "regex-syntax" +version = "0.8.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dc897dd8d9e8bd1ed8cdad82b5966c3e0ecae09fb1907d58efaa013543185d0a" + +[[package]] +name = "restson" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c4e434e0167dbe869e2da4836921fcfbba4a3537716e110ea478350b25434c18" +dependencies = [ + "base64", + "futures", + "hyper", + "hyper-tls", + "log", + "serde", + "serde_json", + "tokio", + "url", +] + +[[package]] +name = "rpassword" +version = "7.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "66d4c8b64f049c6721ec8ccec37ddfc3d641c4a7fca57e8f2a89de509c73df39" +dependencies = [ + "libc", + "rtoolbox", + "windows-sys 0.59.0", +] + +[[package]] +name = "rtoolbox" +version = "0.0.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a7cc970b249fbe527d6e02e0a227762c9108b2f49d81094fe357ffc6d14d7f6f" +dependencies = [ + "libc", + "windows-sys 0.52.0", +] + +[[package]] +name = "rustix" +version = "1.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b6fe4565b9518b83ef4f91bb47ce29620ca828bd32cb7e408f0062e9930ba190" +dependencies = [ + "bitflags", + "errno", + "libc", + "linux-raw-sys", + "windows-sys 0.61.2", +] + +[[package]] +name = "rustversion" +version = "1.0.22" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b39cdef0fa800fc44525c84ccb54a029961a8215f9619753635a9c0d2538d46d" + +[[package]] +name = "ryu" +version = "1.0.23" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9774ba4a74de5f7b1c1451ed6cd5285a32eddb5cccb8cc655a4e50009e06477f" + +[[package]] +name = "schannel" +version = "0.1.28" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "891d81b926048e76efe18581bf793546b4c0eaf8448d72be8de2bbee5fd166e1" +dependencies = [ + "windows-sys 0.61.2", +] + +[[package]] +name = "security-framework" +version = "3.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b7f4bc775c73d9a02cde8bf7b2ec4c9d12743edf609006c7facc23998404cd1d" +dependencies = [ + "bitflags", + "core-foundation", + "core-foundation-sys", + "libc", + "security-framework-sys", +] + +[[package]] +name = "security-framework-sys" +version = "2.17.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6ce2691df843ecc5d231c0b14ece2acc3efb62c0a398c7e1d875f3983ce020e3" +dependencies = [ + "core-foundation-sys", + "libc", +] + +[[package]] +name = "semver" +version = "1.0.27" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d767eb0aabc880b29956c35734170f26ed551a859dbd361d140cdbeca61ab1e2" + +[[package]] +name = "serde" +version = "1.0.228" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9a8e94ea7f378bd32cbbd37198a4a91436180c5bb472411e48b5ec2e2124ae9e" +dependencies = [ + "serde_core", + "serde_derive", +] + +[[package]] +name = "serde_core" +version = "1.0.228" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "41d385c7d4ca58e59fc732af25c3983b67ac852c1a25000afe1175de458b67ad" +dependencies = [ + "serde_derive", +] + +[[package]] +name = "serde_derive" +version = "1.0.228" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d540f220d3187173da220f885ab66608367b6574e925011a9353e4badda91d79" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "serde_json" +version = "1.0.149" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "83fc039473c5595ace860d8c4fafa220ff474b3fc6bfdb4293327f1a37e94d86" +dependencies = [ + "itoa", + "memchr", + "serde", + "serde_core", + "zmij", +] + +[[package]] +name = "serde_qs" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ac22439301a0b6f45a037681518e3169e8db1db76080e2e9600a08d1027df037" +dependencies = [ + "itoa", + "percent-encoding", + "ryu", + "serde", +] + +[[package]] +name = "shlex" +version = "1.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0fda2ff0d084019ba4d7c6f371c95d8fd75ce3524c3cb8fb653a3023f6323e64" + +[[package]] +name = "slab" +version = "0.4.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0c790de23124f9ab44544d7ac05d60440adc586479ce501c1d6d7da3cd8c9cf5" + +[[package]] +name = "smallvec" +version = "1.15.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "67b1b7a3b5fe4f1376887184045fcf45c69e92af734b7aaddc05fb777b6fbd03" + +[[package]] +name = "socket2" +version = "0.5.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e22376abed350d73dd1cd119b57ffccad95b4e585a7cda43e286245ce23c0678" +dependencies = [ + "libc", + "windows-sys 0.52.0", +] + +[[package]] +name = "socket2" +version = "0.6.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "86f4aa3ad99f2088c990dfa82d367e19cb29268ed67c574d10d0a4bfe71f07e0" +dependencies = [ + "libc", + "windows-sys 0.60.2", +] + +[[package]] +name = "spond-api" +version = "0.1.0" +dependencies = [ + "bon", + "chrono", + "restson", + "serde", + "serde_json", + "thiserror", +] + +[[package]] +name = "spond-choose" +version = "0.1.0" +dependencies = [ + "anyhow", + "bon", + "chrono", + "clap", + "env_logger", + "futures", + "http 1.4.0", + "log", + "rand", + "restson", + "rpassword", + "serde", + "serde_json", + "serde_qs", + "spond-api", + "thiserror", + "tokio", + "url", + "xdg", +] + +[[package]] +name = "spond-macros" +version = "0.1.0" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "stable_deref_trait" +version = "1.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6ce2be8dc25455e1f91df71bfa12ad37d7af1092ae736f3a6cd0e37bc7810596" + +[[package]] +name = "strsim" +version = "0.11.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7da8b5736845d9f2fcb837ea5d9e2628564b3b043a70948a3f0b778838c5fb4f" + +[[package]] +name = "syn" +version = "2.0.117" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e665b8803e7b1d2a727f4023456bbbbe74da67099c585258af0ad9c5013b9b99" +dependencies = [ + "proc-macro2", + "quote", + "unicode-ident", +] + +[[package]] +name = "synstructure" +version = "0.13.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "728a70f3dbaf5bab7f0c4b1ac8d7ae5ea60a4b5549c8a5914361c99147a709d2" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "tempfile" +version = "3.26.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "82a72c767771b47409d2345987fda8628641887d5466101319899796367354a0" +dependencies = [ + "fastrand", + "getrandom", + "once_cell", + "rustix", + "windows-sys 0.61.2", +] + +[[package]] +name = "thiserror" +version = "2.0.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4288b5bcbc7920c07a1149a35cf9590a2aa808e0bc1eafaade0b80947865fbc4" +dependencies = [ + "thiserror-impl", +] + +[[package]] +name = "thiserror-impl" +version = "2.0.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ebc4ee7f67670e9b64d05fa4253e753e016c6c95ff35b89b7941d6b856dec1d5" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "tinystr" +version = "0.8.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "42d3e9c45c09de15d06dd8acf5f4e0e399e85927b7f00711024eb7ae10fa4869" +dependencies = [ + "displaydoc", + "zerovec", +] + +[[package]] +name = "tokio" +version = "1.49.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "72a2903cd7736441aac9df9d7688bd0ce48edccaadf181c3b90be801e81d3d86" +dependencies = [ + "bytes", + "libc", + "mio", + "pin-project-lite", + "socket2 0.6.2", + "tokio-macros", + "windows-sys 0.61.2", +] + +[[package]] +name = "tokio-macros" +version = "2.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "af407857209536a95c8e56f8231ef2c2e2aff839b22e07a1ffcbc617e9db9fa5" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "tokio-native-tls" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bbae76ab933c85776efabc971569dd6119c580d8f5d448769dec1764bf796ef2" +dependencies = [ + "native-tls", + "tokio", +] + +[[package]] +name = "tokio-util" +version = "0.7.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9ae9cec805b01e8fc3fd2fe289f89149a9b66dd16786abd8b19cfa7b48cb0098" +dependencies = [ + "bytes", + "futures-core", + "futures-sink", + "pin-project-lite", + "tokio", +] + +[[package]] +name = "tower-service" +version = "0.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8df9b6e13f2d32c91b9bd719c00d1958837bc7dec474d94952798cc8e69eeec3" + +[[package]] +name = "tracing" +version = "0.1.44" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "63e71662fa4b2a2c3a26f570f037eb95bb1f85397f3cd8076caed2f026a6d100" +dependencies = [ + "pin-project-lite", + "tracing-core", +] + +[[package]] +name = "tracing-core" +version = "0.1.36" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "db97caf9d906fbde555dd62fa95ddba9eecfd14cb388e4f491a66d74cd5fb79a" +dependencies = [ + "once_cell", +] + +[[package]] +name = "try-lock" +version = "0.2.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e421abadd41a4225275504ea4d6566923418b7f05506fbc9c0fe86ba7396114b" + +[[package]] +name = "unicode-ident" +version = "1.0.24" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e6e4313cd5fcd3dad5cafa179702e2b244f760991f45397d14d4ebf38247da75" + +[[package]] +name = "unicode-xid" +version = "0.2.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ebc1c04c71510c7f702b52b7c350734c9ff1295c464a03335b00bb84fc54f853" + +[[package]] +name = "url" +version = "2.5.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ff67a8a4397373c3ef660812acab3268222035010ab8680ec4215f38ba3d0eed" +dependencies = [ + "form_urlencoded", + "idna", + "percent-encoding", + "serde", +] + +[[package]] +name = "utf8_iter" +version = "1.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b6c140620e7ffbb22c2dee59cafe6084a59b5ffc27a8859a5f0d494b5d52b6be" + +[[package]] +name = "utf8parse" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "06abde3611657adf66d383f00b093d7faecc7fa57071cce2578660c9f1010821" + +[[package]] +name = "vcpkg" +version = "0.2.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "accd4ea62f7bb7a82fe23066fb0957d48ef677f6eeb8215f372f52e48bb32426" + +[[package]] +name = "want" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bfa7760aed19e106de2c7c0b581b509f2f25d3dacaf737cb82ac61bc6d760b0e" +dependencies = [ + "try-lock", +] + +[[package]] +name = "wasi" +version = "0.11.1+wasi-snapshot-preview1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ccf3ec651a847eb01de73ccad15eb7d99f80485de043efb2f370cd654f4ea44b" + +[[package]] +name = "wasip2" +version = "1.0.2+wasi-0.2.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9517f9239f02c069db75e65f174b3da828fe5f5b945c4dd26bd25d89c03ebcf5" +dependencies = [ + "wit-bindgen", +] + +[[package]] +name = "wasip3" +version = "0.4.0+wasi-0.3.0-rc-2026-01-06" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5428f8bf88ea5ddc08faddef2ac4a67e390b88186c703ce6dbd955e1c145aca5" +dependencies = [ + "wit-bindgen", +] + +[[package]] +name = "wasm-bindgen" +version = "0.2.113" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "60722a937f594b7fde9adb894d7c092fc1bb6612897c46368d18e7a20208eff2" +dependencies = [ + "cfg-if", + "once_cell", + "rustversion", + "wasm-bindgen-macro", + "wasm-bindgen-shared", +] + +[[package]] +name = "wasm-bindgen-macro" +version = "0.2.113" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0fac8c6395094b6b91c4af293f4c79371c163f9a6f56184d2c9a85f5a95f3950" +dependencies = [ + "quote", + "wasm-bindgen-macro-support", +] + +[[package]] +name = "wasm-bindgen-macro-support" +version = "0.2.113" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ab3fabce6159dc20728033842636887e4877688ae94382766e00b180abac9d60" +dependencies = [ + "bumpalo", + "proc-macro2", + "quote", + "syn", + "wasm-bindgen-shared", +] + +[[package]] +name = "wasm-bindgen-shared" +version = "0.2.113" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "de0e091bdb824da87dc01d967388880d017a0a9bc4f3bdc0d86ee9f9336e3bb5" +dependencies = [ + "unicode-ident", +] + +[[package]] +name = "wasm-encoder" +version = "0.244.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "990065f2fe63003fe337b932cfb5e3b80e0b4d0f5ff650e6985b1048f62c8319" +dependencies = [ + "leb128fmt", + "wasmparser", +] + +[[package]] +name = "wasm-metadata" +version = "0.244.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bb0e353e6a2fbdc176932bbaab493762eb1255a7900fe0fea1a2f96c296cc909" +dependencies = [ + "anyhow", + "indexmap", + "wasm-encoder", + "wasmparser", +] + +[[package]] +name = "wasmparser" +version = "0.244.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "47b807c72e1bac69382b3a6fb3dbe8ea4c0ed87ff5629b8685ae6b9a611028fe" +dependencies = [ + "bitflags", + "hashbrown 0.15.5", + "indexmap", + "semver", +] + +[[package]] +name = "windows-core" +version = "0.62.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b8e83a14d34d0623b51dce9581199302a221863196a1dde71a7663a4c2be9deb" +dependencies = [ + "windows-implement", + "windows-interface", + "windows-link", + "windows-result", + "windows-strings", +] + +[[package]] +name = "windows-implement" +version = "0.60.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "053e2e040ab57b9dc951b72c264860db7eb3b0200ba345b4e4c3b14f67855ddf" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "windows-interface" +version = "0.59.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3f316c4a2570ba26bbec722032c4099d8c8bc095efccdc15688708623367e358" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "windows-link" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f0805222e57f7521d6a62e36fa9163bc891acd422f971defe97d64e70d0a4fe5" + +[[package]] +name = "windows-result" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7781fa89eaf60850ac3d2da7af8e5242a5ea78d1a11c49bf2910bb5a73853eb5" +dependencies = [ + "windows-link", +] + +[[package]] +name = "windows-strings" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7837d08f69c77cf6b07689544538e017c1bfcf57e34b4c0ff58e6c2cd3b37091" +dependencies = [ + "windows-link", +] + +[[package]] +name = "windows-sys" +version = "0.52.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "282be5f36a8ce781fad8c8ae18fa3f9beff57ec1b52cb3de0789201425d9a33d" +dependencies = [ + "windows-targets 0.52.6", +] + +[[package]] +name = "windows-sys" +version = "0.59.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1e38bc4d79ed67fd075bcc251a1c39b32a1776bbe92e5bef1f0bf1f8c531853b" +dependencies = [ + "windows-targets 0.52.6", +] + +[[package]] +name = "windows-sys" +version = "0.60.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f2f500e4d28234f72040990ec9d39e3a6b950f9f22d3dba18416c35882612bcb" +dependencies = [ + "windows-targets 0.53.5", +] + +[[package]] +name = "windows-sys" +version = "0.61.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ae137229bcbd6cdf0f7b80a31df61766145077ddf49416a728b02cb3921ff3fc" +dependencies = [ + "windows-link", +] + +[[package]] +name = "windows-targets" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9b724f72796e036ab90c1021d4780d4d3d648aca59e491e6b98e725b84e99973" +dependencies = [ + "windows_aarch64_gnullvm 0.52.6", + "windows_aarch64_msvc 0.52.6", + "windows_i686_gnu 0.52.6", + "windows_i686_gnullvm 0.52.6", + "windows_i686_msvc 0.52.6", + "windows_x86_64_gnu 0.52.6", + "windows_x86_64_gnullvm 0.52.6", + "windows_x86_64_msvc 0.52.6", +] + +[[package]] +name = "windows-targets" +version = "0.53.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4945f9f551b88e0d65f3db0bc25c33b8acea4d9e41163edf90dcd0b19f9069f3" +dependencies = [ + "windows-link", + "windows_aarch64_gnullvm 0.53.1", + "windows_aarch64_msvc 0.53.1", + "windows_i686_gnu 0.53.1", + "windows_i686_gnullvm 0.53.1", + "windows_i686_msvc 0.53.1", + "windows_x86_64_gnu 0.53.1", + "windows_x86_64_gnullvm 0.53.1", + "windows_x86_64_msvc 0.53.1", +] + +[[package]] +name = "windows_aarch64_gnullvm" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "32a4622180e7a0ec044bb555404c800bc9fd9ec262ec147edd5989ccd0c02cd3" + +[[package]] +name = "windows_aarch64_gnullvm" +version = "0.53.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a9d8416fa8b42f5c947f8482c43e7d89e73a173cead56d044f6a56104a6d1b53" + +[[package]] +name = "windows_aarch64_msvc" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "09ec2a7bb152e2252b53fa7803150007879548bc709c039df7627cabbd05d469" + +[[package]] +name = "windows_aarch64_msvc" +version = "0.53.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b9d782e804c2f632e395708e99a94275910eb9100b2114651e04744e9b125006" + +[[package]] +name = "windows_i686_gnu" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8e9b5ad5ab802e97eb8e295ac6720e509ee4c243f69d781394014ebfe8bbfa0b" + +[[package]] +name = "windows_i686_gnu" +version = "0.53.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "960e6da069d81e09becb0ca57a65220ddff016ff2d6af6a223cf372a506593a3" + +[[package]] +name = "windows_i686_gnullvm" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0eee52d38c090b3caa76c563b86c3a4bd71ef1a819287c19d586d7334ae8ed66" + +[[package]] +name = "windows_i686_gnullvm" +version = "0.53.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fa7359d10048f68ab8b09fa71c3daccfb0e9b559aed648a8f95469c27057180c" + +[[package]] +name = "windows_i686_msvc" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "240948bc05c5e7c6dabba28bf89d89ffce3e303022809e73deaefe4f6ec56c66" + +[[package]] +name = "windows_i686_msvc" +version = "0.53.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1e7ac75179f18232fe9c285163565a57ef8d3c89254a30685b57d83a38d326c2" + +[[package]] +name = "windows_x86_64_gnu" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "147a5c80aabfbf0c7d901cb5895d1de30ef2907eb21fbbab29ca94c5b08b1a78" + +[[package]] +name = "windows_x86_64_gnu" +version = "0.53.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9c3842cdd74a865a8066ab39c8a7a473c0778a3f29370b5fd6b4b9aa7df4a499" + +[[package]] +name = "windows_x86_64_gnullvm" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "24d5b23dc417412679681396f2b49f3de8c1473deb516bd34410872eff51ed0d" + +[[package]] +name = "windows_x86_64_gnullvm" +version = "0.53.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0ffa179e2d07eee8ad8f57493436566c7cc30ac536a3379fdf008f47f6bb7ae1" + +[[package]] +name = "windows_x86_64_msvc" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "589f6da84c646204747d1270a2a5661ea66ed1cced2631d546fdfb155959f9ec" + +[[package]] +name = "windows_x86_64_msvc" +version = "0.53.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d6bbff5f0aada427a1e5a6da5f1f98158182f26556f345ac9e04d36d0ebed650" + +[[package]] +name = "wit-bindgen" +version = "0.51.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d7249219f66ced02969388cf2bb044a09756a083d0fab1e566056b04d9fbcaa5" +dependencies = [ + "wit-bindgen-rust-macro", +] + +[[package]] +name = "wit-bindgen-core" +version = "0.51.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ea61de684c3ea68cb082b7a88508a8b27fcc8b797d738bfc99a82facf1d752dc" +dependencies = [ + "anyhow", + "heck", + "wit-parser", +] + +[[package]] +name = "wit-bindgen-rust" +version = "0.51.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b7c566e0f4b284dd6561c786d9cb0142da491f46a9fbed79ea69cdad5db17f21" +dependencies = [ + "anyhow", + "heck", + "indexmap", + "prettyplease", + "syn", + "wasm-metadata", + "wit-bindgen-core", + "wit-component", +] + +[[package]] +name = "wit-bindgen-rust-macro" +version = "0.51.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0c0f9bfd77e6a48eccf51359e3ae77140a7f50b1e2ebfe62422d8afdaffab17a" +dependencies = [ + "anyhow", + "prettyplease", + "proc-macro2", + "quote", + "syn", + "wit-bindgen-core", + "wit-bindgen-rust", +] + +[[package]] +name = "wit-component" +version = "0.244.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9d66ea20e9553b30172b5e831994e35fbde2d165325bec84fc43dbf6f4eb9cb2" +dependencies = [ + "anyhow", + "bitflags", + "indexmap", + "log", + "serde", + "serde_derive", + "serde_json", + "wasm-encoder", + "wasm-metadata", + "wasmparser", + "wit-parser", +] + +[[package]] +name = "wit-parser" +version = "0.244.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ecc8ac4bc1dc3381b7f59c34f00b67e18f910c2c0f50015669dde7def656a736" +dependencies = [ + "anyhow", + "id-arena", + "indexmap", + "log", + "semver", + "serde", + "serde_derive", + "serde_json", + "unicode-xid", + "wasmparser", +] + +[[package]] +name = "writeable" +version = "0.6.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9edde0db4769d2dc68579893f2306b26c6ecfbe0ef499b013d731b7b9247e0b9" + +[[package]] +name = "xdg" +version = "3.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2fb433233f2df9344722454bc7e96465c9d03bff9d77c248f9e7523fe79585b5" + +[[package]] +name = "yoke" +version = "0.8.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "72d6e5c6afb84d73944e5cedb052c4680d5657337201555f9f2a16b7406d4954" +dependencies = [ + "stable_deref_trait", + "yoke-derive", + "zerofrom", +] + +[[package]] +name = "yoke-derive" +version = "0.8.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b659052874eb698efe5b9e8cf382204678a0086ebf46982b79d6ca3182927e5d" +dependencies = [ + "proc-macro2", + "quote", + "syn", + "synstructure", +] + +[[package]] +name = "zerofrom" +version = "0.1.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "50cc42e0333e05660c3587f3bf9d0478688e15d870fab3346451ce7f8c9fbea5" +dependencies = [ + "zerofrom-derive", +] + +[[package]] +name = "zerofrom-derive" +version = "0.1.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d71e5d6e06ab090c67b5e44993ec16b72dcbaabc526db883a360057678b48502" +dependencies = [ + "proc-macro2", + "quote", + "syn", + "synstructure", +] + +[[package]] +name = "zerotrie" +version = "0.2.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2a59c17a5562d507e4b54960e8569ebee33bee890c70aa3fe7b97e85a9fd7851" +dependencies = [ + "displaydoc", + "yoke", + "zerofrom", +] + +[[package]] +name = "zerovec" +version = "0.11.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6c28719294829477f525be0186d13efa9a3c602f7ec202ca9e353d310fb9a002" +dependencies = [ + "yoke", + "zerofrom", + "zerovec-derive", +] + +[[package]] +name = "zerovec-derive" +version = "0.11.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "eadce39539ca5cb3985590102671f2567e659fca9666581ad3411d59207951f3" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "zmij" +version = "1.0.21" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b8848ee67ecc8aedbaf3e4122217aff892639231befc6a1b58d29fff4c2cabaa" diff --git a/api/src/authentication.rs b/api/src/authentication.rs index c8f5201..a8c4c6b 100644 --- a/api/src/authentication.rs +++ b/api/src/authentication.rs @@ -1,5 +1,5 @@ +use restson::{Error, Response, RestClient, RestPath}; use serde::{Deserialize, Serialize}; -use restson::{RestClient, RestPath, Error, Response}; #[derive(Debug, Copy, Clone, Serialize)] struct Email<'a> { @@ -37,8 +37,8 @@ impl<'a> RestPath<()> for Token<'a> { } pub mod token { - use serde::{Serialize, Deserialize}; use crate::util::DateTime; + use serde::{Deserialize, Serialize}; use std::ops::Deref; #[derive(Debug, Clone, Serialize, Deserialize)] @@ -114,14 +114,25 @@ where Ok(tokens.into_inner()) } -pub fn email<'a>(client: &'a RestClient, email: &'a str, password: &'a str) -> impl Future> + 'a { +pub fn email<'a>( + client: &'a RestClient, + email: &'a str, + password: &'a str, +) -> impl Future> + 'a { authenticate(client, Email { email, password }) } -pub fn phone<'a>(client: &'a RestClient, phone: &'a str, password: &'a str) -> impl Future> + 'a { +pub fn phone<'a>( + client: &'a RestClient, + phone: &'a str, + password: &'a str, +) -> impl Future> + 'a { authenticate(client, Phone { phone, password }) } -pub fn token<'a>(client: &'a RestClient, token: &'a str) -> impl Future> + 'a { +pub fn token<'a>( + client: &'a RestClient, + token: &'a str, +) -> impl Future> + 'a { authenticate(client, Token { token }) } diff --git a/api/src/lib.rs b/api/src/lib.rs index e71fe94..2799b99 100644 --- a/api/src/lib.rs +++ b/api/src/lib.rs @@ -58,16 +58,13 @@ impl<'a> Query<'a> { } #[derive(Serialize)] +#[derive(Default)] pub enum Order { + #[default] Ascending, Descending, } -impl Default for Order { - fn default() -> Self { - Self::Ascending - } -} impl std::fmt::Display for Order { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { diff --git a/api/src/profile.rs b/api/src/profile.rs index eee352e..7953ce9 100644 --- a/api/src/profile.rs +++ b/api/src/profile.rs @@ -37,8 +37,5 @@ pub async fn identity(client: &RestClient) -> Result { } pub async fn with_id(client: &RestClient, id: Id) -> Result { - Ok(client - .get_with::<_, Profile>(id, &[]) - .await? - .into_inner()) + Ok(client.get_with::<_, Profile>(id, &[]).await?.into_inner()) } diff --git a/api/src/spond.rs b/api/src/spond.rs index f77e3fd..61cb802 100644 --- a/api/src/spond.rs +++ b/api/src/spond.rs @@ -64,13 +64,10 @@ impl Spond { #[builder] pub fn response( &self, - #[builder(start_fn)] - member: MemberId, - #[builder(finish_fn)] - client: &RestClient, - #[builder(default = true)] - accepted: bool, - ) -> impl Future> { + #[builder(start_fn)] member: MemberId, + #[builder(finish_fn)] client: &RestClient, + #[builder(default = true)] accepted: bool, + ) -> impl Future> { response(self.id) .member(member) .accepted(accepted) @@ -78,27 +75,21 @@ impl Spond { } #[builder] - pub fn accept(&self, - #[builder(start_fn)] - member: MemberId, - #[builder(finish_fn)] - client: &RestClient, - ) -> impl Future> { - self.response(member) - .accepted(true) - .call(client) + pub fn accept( + &self, + #[builder(start_fn)] member: MemberId, + #[builder(finish_fn)] client: &RestClient, + ) -> impl Future> { + self.response(member).accepted(true).call(client) } #[builder] - pub fn decline(&self, - #[builder(start_fn)] - member: MemberId, - #[builder(finish_fn)] - client: &RestClient, - ) -> impl Future> { - self.response(member) - .accepted(false) - .call(client) + pub fn decline( + &self, + #[builder(start_fn)] member: MemberId, + #[builder(finish_fn)] client: &RestClient, + ) -> impl Future> { + self.response(member).accepted(false).call(client) } } @@ -198,11 +189,8 @@ pub fn decline( #[builder(start_fn)] spond: Id, #[builder(finish_fn)] client: &RestClient, member: MemberId, -) -> impl std::future::Future> { - response(spond) - .member(member) - .accepted(false) - .call(client) +) -> impl std::future::Future> { + response(spond).member(member).accepted(false).call(client) } #[bon::builder] @@ -210,11 +198,8 @@ pub fn accept( #[builder(start_fn)] spond: Id, #[builder(finish_fn)] client: &RestClient, member: MemberId, -) -> impl std::future::Future> { - response(spond) - .member(member) - .accepted(true) - .call(client) +) -> impl std::future::Future> { + response(spond).member(member).accepted(true).call(client) } #[bon::builder] @@ -236,7 +221,8 @@ pub async fn response( } } - let request = Request{accepted}; - let response: restson::Response = client.put_capture((spond, member), &request).await?; + let request = Request { accepted }; + let response: restson::Response = + client.put_capture((spond, member), &request).await?; Ok(response.into_inner()) } diff --git a/api/src/util/chrono/datetime.rs b/api/src/util/chrono/datetime.rs new file mode 100644 index 0000000..7c746d8 --- /dev/null +++ b/api/src/util/chrono/datetime.rs @@ -0,0 +1,33 @@ +use serde::{Deserialize, Serialize, Serializer}; + +#[derive(Debug, Copy, Clone, Deserialize)] +#[serde(transparent)] +pub struct DateTime(chrono::DateTime); + +impl Serialize for DateTime { + fn serialize(&self, serializer: S) -> Result { + serializer.serialize_str(&self.to_string()) + } +} + +impl Default for DateTime { + fn default() -> Self { + chrono::Utc::now().into() + } +} + +impl std::fmt::Display for DateTime { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + write!( + f, + "{}", + self.0.to_rfc3339_opts(chrono::SecondsFormat::Secs, true,) + ) + } +} + +impl From> for DateTime { + fn from(dt: chrono::DateTime) -> Self { + Self(dt) + } +} diff --git a/api/src/util/chrono/mod.rs b/api/src/util/chrono/mod.rs new file mode 100644 index 0000000..4bf8d6a --- /dev/null +++ b/api/src/util/chrono/mod.rs @@ -0,0 +1,5 @@ +mod datetime; +pub use datetime::DateTime; + +mod timestamp; +pub use timestamp::Timestamp; diff --git a/api/src/util/chrono/timestamp.rs b/api/src/util/chrono/timestamp.rs new file mode 100644 index 0000000..6246c58 --- /dev/null +++ b/api/src/util/chrono/timestamp.rs @@ -0,0 +1,51 @@ +use chrono::TimeZone; +use serde::{Deserialize, Deserializer, Serialize, Serializer}; // for timestamp_millis_opt + +#[derive(Debug, Clone, Copy)] +pub struct Timestamp(chrono::DateTime); + +impl Serialize for Timestamp { + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + serializer.serialize_i64(self.0.timestamp_millis()) + } +} + +impl<'de> Deserialize<'de> for Timestamp { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + let millis = i64::deserialize(deserializer)?; + let dt = chrono::Utc + .timestamp_millis_opt(millis) + .single() + .ok_or_else(|| serde::de::Error::custom("invalid timestamp"))?; + + Ok(Timestamp(dt)) + } +} + +impl Default for Timestamp { + fn default() -> Self { + chrono::Utc::now().into() + } +} + +impl std::fmt::Display for Timestamp { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + write!( + f, + "{}", + self.0.to_rfc3339_opts(chrono::SecondsFormat::Secs, true,) + ) + } +} + +impl>> From for Timestamp { + fn from(dt: I) -> Self { + Self(dt.into()) + } +} diff --git a/api/src/util/id.rs b/api/src/util/id.rs new file mode 100644 index 0000000..5524db4 --- /dev/null +++ b/api/src/util/id.rs @@ -0,0 +1,114 @@ +use serde::{Deserialize, Deserializer, Serialize, Serializer}; +use std::fmt; +use std::hash::{Hash, Hasher}; + +fn short_type_name(full: &str) -> &str { + let generic = full.find('<').unwrap_or(full.len()); + let last_colon = full[..generic].rfind("::").map_or(0, |idx| idx + 2); + + &full[last_colon..] +} + +pub trait Type: Sized { + type Type: fmt::Display + Copy; + + fn name() -> &'static str { + short_type_name(std::any::type_name::()) + } +} + +pub struct Id(T::Type); + +impl AsRef for Id { + fn as_ref(&self) -> &T::Type { + &self.0 + } +} + +impl Copy for Id {} + +impl Clone for Id { + fn clone(&self) -> Self { + *self + } +} + +impl Id { + pub fn new(src: T::Type) -> Self { + Self(src) + } + + pub async fn load( + &self, + client: &restson::RestClient, + ) -> Result + where + T: restson::RestPath>, + T: serde::de::DeserializeOwned, + { Ok(client.get_with::<_, T>(*self, &[]).await?.into_inner()) } +} + +impl fmt::Debug for Id +where + T::Type: fmt::Debug, +{ + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + write!(f, "ID<{}:{}>", T::name(), self.0) + } +} + +impl fmt::Display for Id { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + write!(f, "{}", self.0) + } +} + +impl Serialize for Id +where + T: Type, + T::Type: Serialize, +{ + fn serialize(&self, serializer: S) -> Result { + self.0.serialize(serializer) + } +} + +impl<'de, T> Deserialize<'de> for Id +where + T: Type, + T::Type: Deserialize<'de>, +{ + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + Ok(Self(T::Type::deserialize(deserializer)?)) + } +} + +impl PartialEq for Id +where + T: Type, + T::Type: PartialEq, +{ + fn eq(&self, other: &Self) -> bool { + self.0 == other.0 + } +} + +impl Eq for Id +where + T: Type, + T::Type: Eq, +{ +} + +impl Hash for Id +where + T: Type, + T::Type: Hash, +{ + fn hash(&self, state: &mut H) { + self.0.hash(state) + } +} diff --git a/api/src/util/mod.rs b/api/src/util/mod.rs new file mode 100644 index 0000000..47f33d4 --- /dev/null +++ b/api/src/util/mod.rs @@ -0,0 +1,11 @@ +pub mod chrono; +pub use chrono::{DateTime, Timestamp}; + +pub mod x128; +pub use x128::X128; + +pub mod id; +pub use id::Id; + +pub mod visibility; +pub use visibility::Visibility; diff --git a/api/src/util/visibility.rs b/api/src/util/visibility.rs new file mode 100644 index 0000000..f968528 --- /dev/null +++ b/api/src/util/visibility.rs @@ -0,0 +1,36 @@ +use serde::{Deserialize, Deserializer, Serialize, Serializer}; + +#[derive(Debug, Clone, PartialEq, Eq)] +pub enum Visibility { + Invitees, + Unknown(String), +} + +impl Serialize for Visibility { + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + let s = match self { + Visibility::Invitees => "INVITEES", + Visibility::Unknown(other) => other, + }; + + serializer.serialize_str(s) + } +} + +impl<'de> Deserialize<'de> for Visibility { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + // Borrow when possible + let s = <&str>::deserialize(deserializer)?; + + Ok(match s { + "INVITEES" => Visibility::Invitees, + other => Visibility::Unknown(other.to_owned()), + }) + } +} diff --git a/api/src/util/x128.rs b/api/src/util/x128.rs new file mode 100644 index 0000000..2a0789d --- /dev/null +++ b/api/src/util/x128.rs @@ -0,0 +1,84 @@ +use serde::{Deserialize, Deserializer, Serialize, Serializer}; +use std::fmt; +use std::ops::Deref; +use std::str::FromStr; + +/// Wrapper for u128 that serializes/deserializes as 32-charachter hex +#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash, Default)] +pub struct X128(u128); + +#[derive(Debug, thiserror::Error)] +pub enum Error { + #[error("invalid length: {0}")] + Length(usize), + + #[error("parser error: {0}")] + Parser(#[from] std::num::ParseIntError), +} + +impl X128 { + /// construct a new value + pub fn new(value: u128) -> Self { + Self(value) + } + + /// access the inner value explicitely + pub fn value(&self) -> u128 { + self.0 + } +} + +impl> From for X128 { + fn from(src: T) -> Self { + Self::new(src.into()) + } +} + +impl FromStr for X128 { + type Err = Error; + + fn from_str(s: &str) -> Result { + match s.len() { + 32 => u128::from_str_radix(s, 16) + .map(Self::new) + .map_err(Error::Parser), + len => Err(Error::Length(len)), + } + } +} + +//impl TryFrom<&str> for X128 { +// type Error = Error; +// +// fn try_from(s: &str) -> Result { +// Self::from_str(s) +// } +//} + +impl Deref for X128 { + type Target = u128; + + fn deref(&self) -> &u128 { + &self.0 + } +} + +impl fmt::Display for X128 { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + write!(f, "{:032X}", self.0) + } +} + +impl Serialize for X128 { + fn serialize(&self, serializer: S) -> Result { + serializer.serialize_str(&self.to_string()) + } +} + +impl<'de> Deserialize<'de> for X128 { + fn deserialize>(deserializer: D) -> Result { + let s = String::deserialize(deserializer)?; + + Self::from_str(&s).map_err(serde::de::Error::custom) + } +} diff --git a/cli/Cargo.toml b/cli/Cargo.toml index 4797ca4..617acc8 100644 --- a/cli/Cargo.toml +++ b/cli/Cargo.toml @@ -1,5 +1,5 @@ [package] -name = "tb-rs" +name = "tb-spond-rs" version = "0.1.0" edition = "2024" @@ -20,7 +20,6 @@ serde_json = "1.0.149" serde_qs = "1.0.0" spond-api = { version = "0.1.0", path = "../api" } thiserror = "2.0.18" -#spond-macros = { version = "0.1.0", path = "../macros" } tokio = { version = "1.49.0", features = ["macros", "rt-multi-thread"] } url = "2.5.8" xdg = "3.0.0" diff --git a/cli/src/authentication.rs b/cli/src/authentication.rs index 49a6378..a8aef19 100644 --- a/cli/src/authentication.rs +++ b/cli/src/authentication.rs @@ -1,7 +1,7 @@ -use clap::{Args, ArgGroup}; +use anyhow::{Error, Result}; +use clap::{ArgGroup, Args}; use restson::RestClient; -use anyhow::{Result, Error}; -use std::str::{FromStr}; +use std::str::FromStr; #[derive(Args, Debug)] #[command(group( @@ -29,13 +29,24 @@ fn bearer(mut client: RestClient, token: &str) -> Result { impl Authentication { pub async fn apply(&self, client: RestClient) -> Result { - let client = match (self.access.as_ref(), self.refresh.as_ref(), self.email.as_ref(), self.phone.as_ref()) { - (Some(ref v), None, None, None) => v.apply(client)?, - (None, Some(ref v), None, None) => v.apply(client).await?, - (None, None, Some(ref v), None) => v.apply(client).await?, - (None, None, None, Some(ref v)) => v.apply(client).await?, + let client = match ( + self.access.as_ref(), + self.refresh.as_ref(), + self.email.as_ref(), + self.phone.as_ref(), + ) { + (Some(v), None, None, None) => v.apply(client)?, + (None, Some(v), None, None) => v.apply(client).await?, + (None, None, Some(v), None) => v.apply(client).await?, + (None, None, None, Some(v)) => v.apply(client).await?, (None, None, None, None) => client, - (a, b, c, d) => anyhow::bail!("invalid authentication: {} + {} + {} + {}", a.is_some(), b.is_some(), c.is_some(), d.is_some()), + (a, b, c, d) => anyhow::bail!( + "invalid authentication: {} + {} + {} + {}", + a.is_some(), + b.is_some(), + c.is_some(), + d.is_some() + ), }; Ok(client) } @@ -63,12 +74,13 @@ impl FromStr for WithPassword { struct Email(WithPassword); impl Email { async fn apply(&self, client: RestClient) -> Result { - let tokens = spond_api::authentication::email(&client, &self.0.value, &self.0.password).await?; + let tokens = + spond_api::authentication::email(&client, &self.0.value, &self.0.password).await?; bearer(client, tokens.access.token.as_ref()) } } impl FromStr for Email { - type Err= ::Err; + type Err = ::Err; fn from_str(s: &str) -> Result { Ok(Self(WithPassword::from_str(s)?)) @@ -79,12 +91,13 @@ impl FromStr for Email { struct Phone(WithPassword); impl Phone { async fn apply(&self, client: RestClient) -> Result { - let tokens = spond_api::authentication::phone(&client, &self.0.value, &self.0.password).await?; + let tokens = + spond_api::authentication::phone(&client, &self.0.value, &self.0.password).await?; bearer(client, tokens.access.token.as_ref()) } } impl FromStr for Phone { - type Err= ::Err; + type Err = ::Err; fn from_str(s: &str) -> Result { Ok(Self(WithPassword::from_str(s)?)) diff --git a/cli/src/main.rs b/cli/src/main.rs index 2471d48..26f1cec 100644 --- a/cli/src/main.rs +++ b/cli/src/main.rs @@ -1,8 +1,8 @@ +use anyhow::Result; use clap::Parser; use restson::RestClient; -use anyhow::Result; -use url::Url; use spond_api as api; +use url::Url; use xdg::BaseDirectories as xdg; mod authentication; @@ -33,7 +33,7 @@ impl Cli { pub async fn client(&self) -> Result { let base = self.base.join("/core/v1/")?; let client = RestClient::new(base.as_str())?; - Ok(self.authentication.apply(client).await?) + self.authentication.apply(client).await } } @@ -42,7 +42,7 @@ struct Seed(u64); impl Default for Seed { fn default() -> Self { - use rand::{rng, RngExt}; + use rand::{RngExt, rng}; Self(rng().random()) } } @@ -68,28 +68,27 @@ impl std::fmt::Display for Seed { } impl Seed { - pub fn shuffle<'a, T, F, W>(&self, input: &'a [T], weight: F) -> Result> + pub fn shuffle(&self, input: &[T], weight: F) -> Result> where F: Fn(T) -> W, W: Into, - T: Copy + T: Copy, { use rand::{SeedableRng, rngs::StdRng}; let len = input.len(); - + let sample = rand::seq::index::sample_weighted( &mut StdRng::seed_from_u64(self.0), len, |idx| weight(input[idx]), len, )?; - + log::debug!("sample: {:?}", sample); Ok(sample.into_iter().map(move |idx| input[idx]).collect()) } } - #[derive(Debug)] struct Weights(std::collections::HashMap); @@ -135,33 +134,30 @@ where impl Weights where - Id: Eq + Hash + Copy + serde::de::DeserializeOwned + Id: Eq + Hash + Copy + serde::de::DeserializeOwned, { pub fn load(serie: api::SeriesId) -> Result { let path = Self::path(serie)?; log::debug!("load {path:?}"); - let file = std::fs::OpenOptions::new() - .read(true) - .open(path)?; + let file = std::fs::OpenOptions::new().read(true).open(path)?; let data: std::collections::HashMap = serde_json::from_reader(file)?; Ok(Self(data)) } } - impl Weights where - Id: Eq + Hash + Copy + serde::Serialize + Id: Eq + Hash + Copy + serde::Serialize, { pub fn store(&self, serie: api::SeriesId) -> Result<()> { use std::fs::{File, rename}; use std::io::{BufWriter, Write}; - let path = Self::path(serie)?; log::debug!("store {path:?}"); let tmp = path.with_extension("json.tmp"); + log::trace!("temporary: {tmp:?}"); // create temporary file let file = File::create(&tmp)?; @@ -180,6 +176,7 @@ where drop(writer); // atomic replace old file + log::trace!("rename {tmp:?} -> {path:?}"); rename(&tmp, &path)?; Ok(()) @@ -195,12 +192,14 @@ async fn main() -> Result<()> { let series = cli.series.map(api::SeriesId::new); let heading = cli.heading.as_ref(); let vip: Vec = if let Some(ref vip) = cli.vip { - vip.into_iter().map(|id| api::MemberId::new(*id)).collect() + vip.iter().map(|id| api::MemberId::new(*id)).collect() } else { [ 0xEB07B45E45E6449386E70A7411816B6Fu128, 0xD05F8574AC544C8DB1A7DC5B6347AA49u128, - ].map(|x| api::MemberId::new(x.into())).into() + ] + .map(|x| api::MemberId::new(x.into())) + .into() }; let client = cli.client().await?; let client = &client; @@ -213,189 +212,123 @@ async fn main() -> Result<()> { log::info!("heading: {heading}"); } - if true { - let now = chrono::Utc::now(); - let sponds = api::spond::search() - .include_comments(true) - .order(api::Order::Ascending) - .max(1000) - .min_start_timestamp(now) - .max_end_timestamp(now + chrono::Duration::weeks(1)) - .call(client).await?; + let now = chrono::Utc::now(); + let sponds = api::spond::search() + .include_comments(true) + .order(api::Order::Ascending) + .max(1000) + .min_start_timestamp(now) + .max_end_timestamp(now + chrono::Duration::weeks(1)) + .call(client) + .await?; - for spond in sponds.iter() - .filter(|spond| { - let result = series.is_none_or(|series| spond.series_id.is_some_and(|remote| remote == series)) - && heading.is_none_or(|heading| spond.heading == *heading); - log::trace!("{}: {:?} == {:?} => {:?}", spond.heading, spond.series_id, series, result); - result - }) - { - log::debug!("{:?}", spond.responses); + for spond in sponds.iter().filter(|spond| { + let result = series + .is_none_or(|series| spond.series_id.is_some_and(|remote| remote == series)) + && heading.is_none_or(|heading| spond.heading == *heading); + log::trace!( + "{}: {:?} == {:?} => {:?}", + spond.heading, + spond.series_id, + series, + result + ); + result + }) { + log::debug!("{:?}", spond.responses); - let spond = &spond; - let decline = |id: &api::MemberId| { - log::info!("remove {0}", *id); - spond.decline(*id).call(client) - }; - let accept = |id: &api::MemberId| { - log::info!("accept {0}", *id); - spond.accept(*id).call(client) - }; + let spond = &spond; + let decline = |id: &api::MemberId| { + log::info!("remove {0}", *id); + spond.decline(*id).call(client) + }; + let accept = |id: &api::MemberId| { + log::info!("accept {0}", *id); + spond.accept(*id).call(client) + }; - let mut weights = spond.series_id.and_then(|series| Weights::load(series).ok()).unwrap_or_else(Weights::default); - log::info!("{weights:?}"); + let mut weights = spond + .series_id + .and_then(|series| Weights::load(series).ok()) + .unwrap_or_else(Weights::default); + log::info!("{weights:?}"); - let (vip, interested) = { - let mut r = (Vec::new(), Vec::new()); - for id in spond.responses.accepted_ids.iter() - .chain(spond.responses.waitinglist_ids.iter()) { - (if vip.contains(id) { &mut r.0 } else { &mut r.1 }).push(*id); - } - (r.0, seed.shuffle(&r.1, |idx| weights.weight(idx))?) - }; - - // remove all registered participants - let results = futures::future::join_all(interested.iter().map(|id|decline(id))).await; - log::debug!("{results:?}"); - - // register them in order - let mut responses = None; - for id in interested.iter() { - responses = Some(accept(id).await?); + let (vip, interested) = { + let mut r = (Vec::new(), Vec::new()); + for id in spond + .responses + .accepted_ids + .iter() + .chain(spond.responses.waitinglist_ids.iter()) + { + (if vip.contains(id) { &mut r.0 } else { &mut r.1 }).push(*id); } + (r.0, seed.shuffle(&r.1, |idx| weights.weight(idx))?) + }; - if let Some(responses) = responses { - log::debug!("{responses:?}"); + // remove all registered participants + let results = futures::future::join_all(interested.iter().map(&decline)).await; + log::debug!("{results:?}"); - let reorder = |mut responses: api::Responses| async move { - // someone might have been registered right now - let mut extra = Vec::new(); - loop { - log::debug!("vip: {vip:?}"); - log::debug!("interested: {interested:?}"); - log::debug!("extra: {extra:?}"); - let reorder = responses.accepted_ids.iter() - .chain(responses.waitinglist_ids.iter()) - .filter(|id| !(vip.contains(*id) || interested.contains(*id) || extra.contains(*id))) + // register them in order + let mut responses = None; + for id in interested.iter() { + responses = Some(accept(id).await?); + } + + if let Some(responses) = responses { + log::debug!("{responses:?}"); + + let reorder = |mut responses: api::Responses| async move { + // someone might have been registered right now + let mut extra = Vec::new(); + loop { + log::debug!("vip: {vip:?}"); + log::debug!("interested: {interested:?}"); + log::debug!("extra: {extra:?}"); + let reorder = responses + .accepted_ids + .iter() + .chain(responses.waitinglist_ids.iter()) + .filter(|id| { + !(vip.contains(*id) + || interested.contains(*id) + || extra.contains(*id)) + }) + .cloned() + .collect::>(); + if reorder.is_empty() { + let update = interested + .iter() + .filter(|id| responses.waitinglist_ids.contains(id)) .cloned() .collect::>(); - if reorder.is_empty() { - let update = interested.iter() - .filter(|id| responses.waitinglist_ids.contains(id)) - .cloned() - .collect::>(); - break Ok::, anyhow::Error>(update); - } - let futures = futures::future::join_all(reorder.iter().map(|id|decline(id))).await; - log::debug!("{futures:?}"); - - for id in reorder.into_iter() { - responses = accept(&id).await?; - extra.push(id); - } - - tokio::time::sleep(tokio::time::Duration::from_secs(10)).await; + break Ok::, anyhow::Error>(update); } - }; + let futures = + futures::future::join_all(reorder.iter().map(&decline)).await; + log::debug!("{futures:?}"); - let update = reorder(responses).await?; - weights.update(&update); - } else { - weights = Weights::default(); + for id in reorder.into_iter() { + responses = accept(&id).await?; + extra.push(id); + } + + tokio::time::sleep(tokio::time::Duration::from_secs(10)).await; + } }; - log::debug!("{weights:?}"); + let update = reorder(responses).await?; + weights.update(&update); + } else { + weights = Weights::default(); + }; - if let Some(series) = spond.series_id { - let _ = weights.store(series)?; - } - } + log::debug!("{weights:?}"); - - //for member in spond.responses.accepted_ids.iter() - // .chain(spond.responses.waitinglist_ids.iter()) { - // let result = map.insert(member, 1); - // println!("{:?}: {:?}", member, result); - //} - //println!("{:?}", map); - //println!("{:?}", &spond.responses); - //let response = spond.response(member) - // .accepted(false) - // .call(&client) - // .await?; - //println!("{:?}", &response); - } else if true { - let profile = api::profile::identity(&client).await; - if let Ok(profile) = profile { - println!("profile: {:?}: {profile}", &profile.id); + if let Some(series) = spond.series_id { + weights.store(series)?; } - } else if false { - //let query = [ - // ("includeSponds", "true"), - //]; - //let series = client.get_with::<_, Series>((0xCCBE049C31DA4FB691158E3FBC2DFBC8u128,), &query).await?.into_inner().0; - let now = api::util::DateTime::default(); - let sponds = api::spond::search() - .include_comments(true) - .order(api::Order::Ascending) - .max(100) - .series_id(api::SeriesId::new(0x9333BDD4135E48BEAE88F1C3006A5FC0u128.into())) - .min_end_timestamp(now) - .min_start_timestamp(now) - .call(&client).await?; - for spond in sponds.iter() { - println!("{spond:?}"); - //let spond = api::spond().call(&client, api::SpondId::new(0xF131CD46F80A42B9909D8E7F4018D8E1u128.into())).await?; - //println!("{spond:?}"); - } - //} else if true { - // - //#[derive(Debug, serde::Deserialize, serde::Serialize)] - //struct Spond(serde_json::Value); - // - //#[derive(Debug, serde::Deserialize, serde::Serialize)] - //struct Sponds(Vec); - // - //impl restson::RestPath<()> for Sponds { - // fn get_path(_: ()) -> std::result::Result { - // Ok(String::from("sponds")) - // } - //} - // let now = &DateTime::default(); - // log::info!("{now:?} | {}", now.to_string()); - // let query = [ - // ("includeComments", "true"), - // //("includeHidden", "true"), - // ("addProfileInfo", "true"), - // ("hidden", "true"), - // ("scheduled", "true"), - // ("order", "asc"), - // ("max", "20"), - // ("heading", "Schwimmtraining Donnerstag"), - // ("seriesId", "CCBE049C31DA4FB691158E3FBC2DFBC8u128"), - // ("minStartTimestamp", &now.to_string()), - // ]; - // - // for spond in client.get_with::<_, api::spond::Sponds>((), &query).await?.into_inner().0 { - // //match spond.0 { - // // serde_json::Value::Object(map) => { - // // println!("{:?}", map); - // // }, - // // _ => {}, - // //}; - // println!("{}", serde_json::to_string_pretty(&spond).unwrap()); - // } - //} else { - // let request = api::sponds() - // .add_profile_info(false) - // .comments(true) - // .hidden(false) - // .scheduled(true) - // ; - // for spond in request.call(&client).await? { - // println!("{spond:?}"); - // } } Ok(()) diff --git a/macros/src/lib.rs b/macros/src/lib.rs index 4296daa..d73b224 100644 --- a/macros/src/lib.rs +++ b/macros/src/lib.rs @@ -47,8 +47,8 @@ fn extract_args(inputs: &Punctuated, class: Class, default: C for arg in inputs.iter().skip(1) { if let syn::FnArg::Typed(pat_type) = arg { //if pat_type.attrs.iter().any(|a| a.path().is_ident(path)) { - if Class::classify(&pat_type, default) == class { - if let syn::Pat::Ident(pat_ident) = &*pat_type.pat { + if Class::classify(pat_type, default) == class + && let syn::Pat::Ident(pat_ident) = &*pat_type.pat { idents.push(pat_ident.ident.clone()); types.push((*pat_type.ty).clone()); let meta = pat_type.attrs.iter() @@ -58,7 +58,6 @@ fn extract_args(inputs: &Punctuated, class: Class, default: C }; attrs.push(meta); } - } } } (idents, types, attrs) From 47c353c7dafb3d5e886c5e05a2c918439d59d153 Mon Sep 17 00:00:00 2001 From: Jonas Rabenstein Date: Thu, 12 Mar 2026 22:19:53 +0100 Subject: [PATCH 13/15] skip if empty waitinglist --- .gitignore | 1 + cli/src/main.rs | 8 ++++++-- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/.gitignore b/.gitignore index 10363bd..05aafb1 100644 --- a/.gitignore +++ b/.gitignore @@ -4,4 +4,5 @@ !/cli/ !Cargo.toml !/*/src/ +!/*/src/**/ !/*/src/**/*.rs diff --git a/cli/src/main.rs b/cli/src/main.rs index 26f1cec..8fff792 100644 --- a/cli/src/main.rs +++ b/cli/src/main.rs @@ -237,6 +237,11 @@ async fn main() -> Result<()> { }) { log::debug!("{:?}", spond.responses); + if spond.responses.waitinglist_ids.is_empty() { + log::info!("nobody on the waiting list"); + continue; + } + let spond = &spond; let decline = |id: &api::MemberId| { log::info!("remove {0}", *id); @@ -313,8 +318,7 @@ async fn main() -> Result<()> { responses = accept(&id).await?; extra.push(id); } - - tokio::time::sleep(tokio::time::Duration::from_secs(10)).await; + tokio::time::sleep(tokio::time::Duration::from_secs(5)).await; } }; From 77bea18eb3b04dcc38c9ffa6a9c6b5bc25c14e80 Mon Sep 17 00:00:00 2001 From: Jonas Rabenstein Date: Thu, 12 Mar 2026 22:20:06 +0100 Subject: [PATCH 14/15] flake: module --- flake.nix | 55 ++++++++++++++++++++++++++++++++++++++++++++++++------- 1 file changed, 48 insertions(+), 7 deletions(-) diff --git a/flake.nix b/flake.nix index 4130f54..f412dc6 100644 --- a/flake.nix +++ b/flake.nix @@ -1,8 +1,8 @@ { outputs = { nixpkgs, ... }: let spond = { rustPlatform, rustfmt, clippy, pkg-config, openssl, ... }: rustPlatform.buildRustPackage { - pname = "spond"; - version = "0.0.0"; + pname = "tb-spond-rs"; + version = "0.1.0"; src = ./.; cargoLock.lockFile = ./Cargo.lock; @@ -14,18 +14,19 @@ ]; }; - allpkgs = system: pkgs: pkgs.extend (_: _: nixpkgs.lib.attrsets.filterAttrs (name: _: name != "default") (packages system pkgs)); + allpkgs = pkgs: pkgs.extend (_: _: nixpkgs.lib.attrsets.filterAttrs (name: _: name != "default") (packages' pkgs)); - packages = system: pkgs': let - pkgs = allpkgs system pkgs'; + packages = system: packages'; + packages' = pkgs': let + pkgs = allpkgs pkgs'; in { default = pkgs.spond; spond = pkgs.callPackage spond {}; }; devShells = system: pkgs': let - pkgs = allpkgs system pkgs'; - in builtins.mapAttrs (devShell pkgs) (packages system pkgs'); + pkgs = allpkgs pkgs'; + in builtins.mapAttrs (devShell pkgs) (packages pkgs'); devShell = pkgs: name: pkg: pkgs.mkShell { buildInputs = with pkgs; [ @@ -57,8 +58,48 @@ printf 'Dev shell for %s ready!\n' '${pkg.name}' ''; }; + + nixosModule = { pkgs, lib, config, ... }: let + cli = lib.getExe (packages' pkgs).spond; + in { + config.systemd.timers."tb-spond-rs" = { + description = "[TB] choose who is allowed to participate this week."; + timerConfig.OnCalendar = "Sat 18:00:00"; + wantedBy = [ "timers.target" ]; + }; + config.systemd.services."tb-spond-rs" = { + description = "[TB] choose who is allowed to participate this week."; + after = [ "network.target" ]; + wants = [ "network.target" ]; + + serviceConfig = { + Type = "simple"; + ExecStart = lib.escapeShellArgs [ + cli + "--email" "jonas.rabenstein@web.de" + "--heading" "Schwimmtraining Donnerstag" + ]; + EnvironmentFile=[ "%d/environment" ]; + User = "tb-spond-rs"; + Group = "tb-spond-rs"; + DynamicUser = true; + RuntimeDirectory = "tb-spond-rs"; + StateDirectory = "tb-spond-rs"; + ProtectSystem = "full"; + ProtectHome = true; + NoNewPrivileges = true; + PrivateTmp = true; + PrivateDevices = true; + }; + }; + }; in { packages = builtins.mapAttrs packages nixpkgs.legacyPackages; devShells = builtins.mapAttrs devShells nixpkgs.legacyPackages; + + nixosModules = { + default = nixosModule; + spond = nixosModule; + }; }; } From 3beb94721bc6879764e814418a0ba73e5f146e04 Mon Sep 17 00:00:00 2001 From: Jonas Rabenstein Date: Fri, 13 Mar 2026 00:27:00 +0100 Subject: [PATCH 15/15] rust 1.86 --- Cargo.lock | 304 ++++++++++++++++++++++------------------------------- Cargo.toml | 2 +- flake.nix | 2 +- 3 files changed, 128 insertions(+), 180 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 9ea0a82..45726fa 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -27,7 +27,22 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "43d5b281e737544384e969a5ccad3f1cdd24b48086a0fc1b2a5262a26b8f4f4a" dependencies = [ "anstyle", - "anstyle-parse", + "anstyle-parse 0.2.7", + "anstyle-query", + "anstyle-wincon", + "colorchoice", + "is_terminal_polyfill", + "utf8parse", +] + +[[package]] +name = "anstream" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "824a212faf96e9acacdbd09febd34438f8f711fb84e09a8916013cd7815ca28d" +dependencies = [ + "anstyle", + "anstyle-parse 1.0.0", "anstyle-query", "anstyle-wincon", "colorchoice", @@ -50,6 +65,15 @@ dependencies = [ "utf8parse", ] +[[package]] +name = "anstyle-parse" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "52ce7f38b242319f7cabaa6813055467063ecdc9d355bbb4ce0c68908cd8130e" +dependencies = [ + "utf8parse", +] + [[package]] name = "anstyle-query" version = "1.1.5" @@ -174,9 +198,9 @@ dependencies = [ [[package]] name = "clap" -version = "4.5.60" +version = "4.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2797f34da339ce31042b27d23607e051786132987f595b02ba4f6a6dffb7030a" +checksum = "b193af5b67834b676abd72466a96c1024e6a6ad978a1f484bd90b85c94041351" dependencies = [ "clap_builder", "clap_derive", @@ -184,11 +208,11 @@ dependencies = [ [[package]] name = "clap_builder" -version = "4.5.60" +version = "4.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "24a241312cea5059b13574bb9b3861cabf758b879c15190b37b6d6fd63ab6876" +checksum = "714a53001bf66416adb0e2ef5ac857140e7dc3a0c48fb28b2f10762fc4b5069f" dependencies = [ - "anstream", + "anstream 1.0.0", "anstyle", "clap_lex", "strsim", @@ -196,9 +220,9 @@ dependencies = [ [[package]] name = "clap_derive" -version = "4.5.55" +version = "4.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a92793da1a46a5f2a02a6f4c46c6496b28c43638adea8306fcb0caa1634f24e5" +checksum = "1110bd8a634a1ab8cb04345d8d878267d57c3cf1b38d91b71af6686408bbca6a" dependencies = [ "heck", "proc-macro2", @@ -208,9 +232,9 @@ dependencies = [ [[package]] name = "clap_lex" -version = "1.0.0" +version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3a822ea5bc7590f9d40f1ba12c0dc3c2760f3482c6984db1573ad11031420831" +checksum = "c8d4a3bb8b1e0c1050499d1815f5ab16d04f0959b233085fb31653fbfc9d98f9" [[package]] name = "colorchoice" @@ -245,9 +269,9 @@ dependencies = [ [[package]] name = "darling" -version = "0.23.0" +version = "0.21.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "25ae13da2f202d56bd7f91c25fba009e7717a1e4a1cc98a76d844b65ae912e9d" +checksum = "9cdf337090841a411e2a7f3deb9187445851f91b309c0c0a29e05f74a00a48c0" dependencies = [ "darling_core", "darling_macro", @@ -255,10 +279,11 @@ dependencies = [ [[package]] name = "darling_core" -version = "0.23.0" +version = "0.21.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9865a50f7c335f53564bb694ef660825eb8610e0a53d3e11bf1b0d3df31e03b0" +checksum = "1247195ecd7e3c85f83c8d2a366e4210d588e802133e1e355180a9870b517ea4" dependencies = [ + "fnv", "ident_case", "proc-macro2", "quote", @@ -268,9 +293,9 @@ dependencies = [ [[package]] name = "darling_macro" -version = "0.23.0" +version = "0.21.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ac3984ec7bd6cfa798e62b4a642426a5be0e68f9401cfc2a01e3fa9ea2fcdb8d" +checksum = "d38308df82d1080de0afee5d069fa14b0326a88c14f15c5ccda35b4a6c414c81" dependencies = [ "darling_core", "quote", @@ -304,7 +329,7 @@ version = "0.11.9" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b2daee4ea451f429a58296525ddf28b45a3b64f1acf6587e2067437bb11e218d" dependencies = [ - "anstream", + "anstream 0.6.21", "anstyle", "env_filter", "jiff", @@ -465,9 +490,9 @@ dependencies = [ [[package]] name = "getrandom" -version = "0.4.1" +version = "0.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "139ef39800118c7683f2fd3c98c1b23c09ae076556b435f8e9064ae108aaeeec" +checksum = "0de51e6874e94e7bf76d726fc5d13ba782deca734ff60d5bb2fb2607c7406555" dependencies = [ "cfg-if", "libc", @@ -762,9 +787,9 @@ checksum = "92ecc6618181def0457392ccd0ee51198e065e016d1d527a7ac1b6dc7c1f09d2" [[package]] name = "jiff" -version = "0.2.21" +version = "0.2.23" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b3e3d65f018c6ae946ab16e80944b97096ed73c35b221d1c478a6c81d8f57940" +checksum = "1a3546dc96b6d42c5f24902af9e2538e82e39ad350b0c766eb3fbf2d8f3d8359" dependencies = [ "jiff-static", "log", @@ -775,9 +800,9 @@ dependencies = [ [[package]] name = "jiff-static" -version = "0.2.21" +version = "0.2.23" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a17c2b211d863c7fde02cbea8a3c1a439b98e109286554f2860bdded7ff83818" +checksum = "2a8c8b344124222efd714b73bb41f8b5120b27a7cc1c75593a6ff768d9d05aa4" dependencies = [ "proc-macro2", "quote", @@ -786,9 +811,9 @@ dependencies = [ [[package]] name = "js-sys" -version = "0.3.90" +version = "0.3.91" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "14dc6f6450b3f6d4ed5b16327f38fed626d375a886159ca555bd7822c0c3a5a6" +checksum = "b49715b7073f385ba4bc528e5747d02e66cb39c6146efb66b781f131f0fb399c" dependencies = [ "once_cell", "wasm-bindgen", @@ -802,9 +827,9 @@ checksum = "09edd9e8b54e49e587e4f6295a7d29c3ea94d469cb40ab8ca70b288248a81db2" [[package]] name = "libc" -version = "0.2.182" +version = "0.2.183" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6800badb6cb2082ffd7b6a67e6125bb39f18782f793520caee8cb8846be06112" +checksum = "b5b646652bf6661599e1da8901b3b9522896f01e736bad5f723fe7a3a27f899d" [[package]] name = "linux-raw-sys" @@ -869,9 +894,9 @@ dependencies = [ [[package]] name = "once_cell" -version = "1.21.3" +version = "1.21.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "42f5e15c9953c5e4ccceeb2e7382a716482c34515315f7b03532b8b4e8393d2d" +checksum = "9f7c3e4beb33f85d45ae3e3a1792185706c8e16d043238c593331cc7cd313b50" [[package]] name = "once_cell_polyfill" @@ -881,9 +906,9 @@ checksum = "384b8ab6d37215f3c5301a95a4accb5d64aa607f1fcb26a11b5303878451b4fe" [[package]] name = "openssl" -version = "0.10.75" +version = "0.10.76" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "08838db121398ad17ab8531ce9de97b244589089e290a384c900cb9ff7434328" +checksum = "951c002c75e16ea2c65b8c7e4d3d51d5530d8dfa7d060b4776828c88cfb18ecf" dependencies = [ "bitflags", "cfg-if", @@ -913,9 +938,9 @@ checksum = "7c87def4c32ab89d880effc9e097653c8da5d6ef28e6b539d313baaacfbafcbe" [[package]] name = "openssl-sys" -version = "0.9.111" +version = "0.9.112" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "82cab2d520aa75e3c58898289429321eb788c3106963d0dc886ec7a5f4adc321" +checksum = "57d55af3b3e226502be1526dfdba67ab0e9c96fc293004e79576b2b9edb0dbdb" dependencies = [ "cc", "libc", @@ -931,9 +956,9 @@ checksum = "9b4f627cb1b25917193a259e49bdad08f671f8d9708acfd5fe0a8c1455d87220" [[package]] name = "pin-project-lite" -version = "0.2.16" +version = "0.2.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3b3cff922bd51709b605d9ead9aa71031d81447142d828eb4a6eba76fe619f9b" +checksum = "a89322df9ebe1c1578d689c92318e070967d1042b512afbe49518723f4e6d5cd" [[package]] name = "pkg-config" @@ -986,18 +1011,18 @@ dependencies = [ [[package]] name = "quote" -version = "1.0.44" +version = "1.0.45" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "21b2ebcf727b7760c461f091f9f0f539b77b8e87f2fd88131e7f1b433b3cece4" +checksum = "41f2619966050689382d2b44f664f4bc593e129785a36d6ee376ddf37259b924" dependencies = [ "proc-macro2", ] [[package]] name = "r-efi" -version = "5.3.0" +version = "6.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "69cdb34c158ceb288df11e18b4bd39de994f6657d83847bdffdbd7f346754b0f" +checksum = "f8dcc9c7d52a811697d2151c701e0d08956f92b0e24136cf4cf27b57a6a0d9bf" [[package]] name = "rand" @@ -1110,9 +1135,9 @@ checksum = "9774ba4a74de5f7b1c1451ed6cd5285a32eddb5cccb8cc655a4e50009e06477f" [[package]] name = "schannel" -version = "0.1.28" +version = "0.1.29" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "891d81b926048e76efe18581bf793546b4c0eaf8448d72be8de2bbee5fd166e1" +checksum = "91c1b7e4904c873ef0710c1f407dde2e6287de2bebc1bbbf7d430bb7cbffd939" dependencies = [ "windows-sys 0.61.2", ] @@ -1231,12 +1256,12 @@ dependencies = [ [[package]] name = "socket2" -version = "0.6.2" +version = "0.6.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "86f4aa3ad99f2088c990dfa82d367e19cb29268ed67c574d10d0a4bfe71f07e0" +checksum = "3a766e1110788c36f4fa1c2b71b387a7815aa65f88ce0229841826633d93723e" dependencies = [ "libc", - "windows-sys 0.60.2", + "windows-sys 0.61.2", ] [[package]] @@ -1251,40 +1276,6 @@ dependencies = [ "thiserror", ] -[[package]] -name = "spond-choose" -version = "0.1.0" -dependencies = [ - "anyhow", - "bon", - "chrono", - "clap", - "env_logger", - "futures", - "http 1.4.0", - "log", - "rand", - "restson", - "rpassword", - "serde", - "serde_json", - "serde_qs", - "spond-api", - "thiserror", - "tokio", - "url", - "xdg", -] - -[[package]] -name = "spond-macros" -version = "0.1.0" -dependencies = [ - "proc-macro2", - "quote", - "syn", -] - [[package]] name = "stable_deref_trait" version = "1.2.1" @@ -1319,11 +1310,36 @@ dependencies = [ "syn", ] +[[package]] +name = "tb-spond-rs" +version = "0.1.0" +dependencies = [ + "anyhow", + "bon", + "chrono", + "clap", + "env_logger", + "futures", + "http 1.4.0", + "log", + "rand", + "restson", + "rpassword", + "serde", + "serde_json", + "serde_qs", + "spond-api", + "thiserror", + "tokio", + "url", + "xdg", +] + [[package]] name = "tempfile" -version = "3.26.0" +version = "3.27.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "82a72c767771b47409d2345987fda8628641887d5466101319899796367354a0" +checksum = "32497e9a4c7b38532efcdebeef879707aa9f794296a4f0244f6f69e9bc8574bd" dependencies = [ "fastrand", "getrandom", @@ -1364,24 +1380,24 @@ dependencies = [ [[package]] name = "tokio" -version = "1.49.0" +version = "1.50.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "72a2903cd7736441aac9df9d7688bd0ce48edccaadf181c3b90be801e81d3d86" +checksum = "27ad5e34374e03cfffefc301becb44e9dc3c17584f414349ebe29ed26661822d" dependencies = [ "bytes", "libc", "mio", "pin-project-lite", - "socket2 0.6.2", + "socket2 0.6.3", "tokio-macros", "windows-sys 0.61.2", ] [[package]] name = "tokio-macros" -version = "2.6.0" +version = "2.6.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "af407857209536a95c8e56f8231ef2c2e2aff839b22e07a1ffcbc617e9db9fa5" +checksum = "5c55a2eff8b69ce66c84f85e1da1c233edc36ceb85a2058d11b0d6a3c7e7569c" dependencies = [ "proc-macro2", "quote", @@ -1501,11 +1517,11 @@ checksum = "ccf3ec651a847eb01de73ccad15eb7d99f80485de043efb2f370cd654f4ea44b" [[package]] name = "wasip2" -version = "1.0.2+wasi-0.2.9" +version = "1.0.1+wasi-0.2.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9517f9239f02c069db75e65f174b3da828fe5f5b945c4dd26bd25d89c03ebcf5" +checksum = "0562428422c63773dad2c345a1882263bbf4d65cf3f42e90921f787ef5ad58e7" dependencies = [ - "wit-bindgen", + "wit-bindgen 0.46.0", ] [[package]] @@ -1514,14 +1530,14 @@ version = "0.4.0+wasi-0.3.0-rc-2026-01-06" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5428f8bf88ea5ddc08faddef2ac4a67e390b88186c703ce6dbd955e1c145aca5" dependencies = [ - "wit-bindgen", + "wit-bindgen 0.51.0", ] [[package]] name = "wasm-bindgen" -version = "0.2.113" +version = "0.2.114" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "60722a937f594b7fde9adb894d7c092fc1bb6612897c46368d18e7a20208eff2" +checksum = "6532f9a5c1ece3798cb1c2cfdba640b9b3ba884f5db45973a6f442510a87d38e" dependencies = [ "cfg-if", "once_cell", @@ -1532,9 +1548,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-macro" -version = "0.2.113" +version = "0.2.114" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0fac8c6395094b6b91c4af293f4c79371c163f9a6f56184d2c9a85f5a95f3950" +checksum = "18a2d50fcf105fb33bb15f00e7a77b772945a2ee45dcf454961fd843e74c18e6" dependencies = [ "quote", "wasm-bindgen-macro-support", @@ -1542,9 +1558,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-macro-support" -version = "0.2.113" +version = "0.2.114" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ab3fabce6159dc20728033842636887e4877688ae94382766e00b180abac9d60" +checksum = "03ce4caeaac547cdf713d280eda22a730824dd11e6b8c3ca9e42247b25c631e3" dependencies = [ "bumpalo", "proc-macro2", @@ -1555,9 +1571,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-shared" -version = "0.2.113" +version = "0.2.114" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "de0e091bdb824da87dc01d967388880d017a0a9bc4f3bdc0d86ee9f9336e3bb5" +checksum = "75a326b8c223ee17883a4251907455a2431acc2791c98c26279376490c378c16" dependencies = [ "unicode-ident", ] @@ -1661,7 +1677,7 @@ version = "0.52.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "282be5f36a8ce781fad8c8ae18fa3f9beff57ec1b52cb3de0789201425d9a33d" dependencies = [ - "windows-targets 0.52.6", + "windows-targets", ] [[package]] @@ -1670,16 +1686,7 @@ version = "0.59.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1e38bc4d79ed67fd075bcc251a1c39b32a1776bbe92e5bef1f0bf1f8c531853b" dependencies = [ - "windows-targets 0.52.6", -] - -[[package]] -name = "windows-sys" -version = "0.60.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f2f500e4d28234f72040990ec9d39e3a6b950f9f22d3dba18416c35882612bcb" -dependencies = [ - "windows-targets 0.53.5", + "windows-targets", ] [[package]] @@ -1697,31 +1704,14 @@ version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9b724f72796e036ab90c1021d4780d4d3d648aca59e491e6b98e725b84e99973" dependencies = [ - "windows_aarch64_gnullvm 0.52.6", - "windows_aarch64_msvc 0.52.6", - "windows_i686_gnu 0.52.6", - "windows_i686_gnullvm 0.52.6", - "windows_i686_msvc 0.52.6", - "windows_x86_64_gnu 0.52.6", - "windows_x86_64_gnullvm 0.52.6", - "windows_x86_64_msvc 0.52.6", -] - -[[package]] -name = "windows-targets" -version = "0.53.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4945f9f551b88e0d65f3db0bc25c33b8acea4d9e41163edf90dcd0b19f9069f3" -dependencies = [ - "windows-link", - "windows_aarch64_gnullvm 0.53.1", - "windows_aarch64_msvc 0.53.1", - "windows_i686_gnu 0.53.1", - "windows_i686_gnullvm 0.53.1", - "windows_i686_msvc 0.53.1", - "windows_x86_64_gnu 0.53.1", - "windows_x86_64_gnullvm 0.53.1", - "windows_x86_64_msvc 0.53.1", + "windows_aarch64_gnullvm", + "windows_aarch64_msvc", + "windows_i686_gnu", + "windows_i686_gnullvm", + "windows_i686_msvc", + "windows_x86_64_gnu", + "windows_x86_64_gnullvm", + "windows_x86_64_msvc", ] [[package]] @@ -1730,84 +1720,42 @@ version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "32a4622180e7a0ec044bb555404c800bc9fd9ec262ec147edd5989ccd0c02cd3" -[[package]] -name = "windows_aarch64_gnullvm" -version = "0.53.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a9d8416fa8b42f5c947f8482c43e7d89e73a173cead56d044f6a56104a6d1b53" - [[package]] name = "windows_aarch64_msvc" version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "09ec2a7bb152e2252b53fa7803150007879548bc709c039df7627cabbd05d469" -[[package]] -name = "windows_aarch64_msvc" -version = "0.53.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b9d782e804c2f632e395708e99a94275910eb9100b2114651e04744e9b125006" - [[package]] name = "windows_i686_gnu" version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8e9b5ad5ab802e97eb8e295ac6720e509ee4c243f69d781394014ebfe8bbfa0b" -[[package]] -name = "windows_i686_gnu" -version = "0.53.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "960e6da069d81e09becb0ca57a65220ddff016ff2d6af6a223cf372a506593a3" - [[package]] name = "windows_i686_gnullvm" version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0eee52d38c090b3caa76c563b86c3a4bd71ef1a819287c19d586d7334ae8ed66" -[[package]] -name = "windows_i686_gnullvm" -version = "0.53.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fa7359d10048f68ab8b09fa71c3daccfb0e9b559aed648a8f95469c27057180c" - [[package]] name = "windows_i686_msvc" version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "240948bc05c5e7c6dabba28bf89d89ffce3e303022809e73deaefe4f6ec56c66" -[[package]] -name = "windows_i686_msvc" -version = "0.53.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1e7ac75179f18232fe9c285163565a57ef8d3c89254a30685b57d83a38d326c2" - [[package]] name = "windows_x86_64_gnu" version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "147a5c80aabfbf0c7d901cb5895d1de30ef2907eb21fbbab29ca94c5b08b1a78" -[[package]] -name = "windows_x86_64_gnu" -version = "0.53.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9c3842cdd74a865a8066ab39c8a7a473c0778a3f29370b5fd6b4b9aa7df4a499" - [[package]] name = "windows_x86_64_gnullvm" version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "24d5b23dc417412679681396f2b49f3de8c1473deb516bd34410872eff51ed0d" -[[package]] -name = "windows_x86_64_gnullvm" -version = "0.53.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0ffa179e2d07eee8ad8f57493436566c7cc30ac536a3379fdf008f47f6bb7ae1" - [[package]] name = "windows_x86_64_msvc" version = "0.52.6" @@ -1815,10 +1763,10 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "589f6da84c646204747d1270a2a5661ea66ed1cced2631d546fdfb155959f9ec" [[package]] -name = "windows_x86_64_msvc" -version = "0.53.1" +name = "wit-bindgen" +version = "0.46.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d6bbff5f0aada427a1e5a6da5f1f98158182f26556f345ac9e04d36d0ebed650" +checksum = "f17a85883d4e6d00e8a97c586de764dabcc06133f7f1d55dce5cdc070ad7fe59" [[package]] name = "wit-bindgen" diff --git a/Cargo.toml b/Cargo.toml index 67a02f0..cd64b5b 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,4 +1,4 @@ [workspace] resolver = "3" #members = ["api","cli","schema"] -members = ["api", "cli" , "macros"] +members = ["api", "cli" ] diff --git a/flake.nix b/flake.nix index f412dc6..92bd055 100644 --- a/flake.nix +++ b/flake.nix @@ -26,7 +26,7 @@ devShells = system: pkgs': let pkgs = allpkgs pkgs'; - in builtins.mapAttrs (devShell pkgs) (packages pkgs'); + in builtins.mapAttrs (devShell pkgs) (packages' pkgs'); devShell = pkgs: name: pkg: pkgs.mkShell { buildInputs = with pkgs; [