diff --git a/Cargo.lock b/Cargo.lock index 0917931..efa3175 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -224,28 +224,16 @@ name = "blah" version = "0.0.0" dependencies = [ "anyhow", - "axum", "bitflags", "bitflags_serde_shim", - "clap", "ed25519-dalek", - "futures-util", "hex", "html-escape", - "humantime", "rand_core", "rusqlite", - "sd-notify", "serde", - "serde-aux", - "serde-constant", "serde_json", "syn", - "tokio", - "tokio-stream", - "tower-http", - "tracing", - "tracing-subscriber", "uuid", ] @@ -254,7 +242,6 @@ name = "blahctl" version = "0.1.0" dependencies = [ "anyhow", - "bitflags", "blah", "clap", "ed25519-dalek", @@ -263,6 +250,30 @@ dependencies = [ "reqwest", "rusqlite", "tokio", +] + +[[package]] +name = "blahd" +version = "0.0.0" +dependencies = [ + "anyhow", + "axum", + "blah", + "clap", + "ed25519-dalek", + "futures-util", + "hex", + "humantime", + "rusqlite", + "sd-notify", + "serde", + "serde-aux", + "serde_json", + "tokio", + "tokio-stream", + "tower-http", + "tracing", + "tracing-subscriber", "uuid", ] @@ -462,7 +473,6 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "115531babc129696a58c64a4fef0a8bf9e9698629fb97e9e40767d235cfbcd53" dependencies = [ "pkcs8", - "serde", "signature", ] @@ -477,7 +487,6 @@ dependencies = [ "rand_core", "serde", "sha2", - "signature", "subtle", "zeroize", ] @@ -1414,15 +1423,6 @@ dependencies = [ "serde_json", ] -[[package]] -name = "serde-constant" -version = "0.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "301d0de95fe56444b1ea1ee62363452b756fe715fb4eab505be16b906599b47e" -dependencies = [ - "serde", -] - [[package]] name = "serde_derive" version = "1.0.209" @@ -1500,7 +1500,6 @@ version = "2.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "77549399552de45a898a580c1b41d445bf730df867cc44e6c0233bbc4b8329de" dependencies = [ - "digest", "rand_core", ] diff --git a/Cargo.toml b/Cargo.toml index 54b402c..4e0eed7 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,36 +1,29 @@ +[workspace] +resolver = "2" +members = [ + ".", + "blahctl", + "blahd", +] +default-members = ["blahd"] + [package] name = "blah" version = "0.0.0" edition = "2021" -# TODO: Shrink dependencies. [dependencies] -anyhow = "1.0.86" -axum = { version = "0.7.5", features = ["tokio"] } -bitflags = "2.6.0" -bitflags_serde_shim = "0.2.5" -clap = { version = "4.5.16", features = ["derive"] } -ed25519-dalek = { version = "2.1.1", features = ["digest", "serde"] } -futures-util = "0.3.30" -hex = { version = "0.4.3", features = ["serde"] } -html-escape = "0.2.13" -humantime = "2.1.0" -rand_core = "0.6.4" -rusqlite = { version = "0.32.1", features = ["uuid"] } -sd-notify = "0.4.2" -serde = { version = "1.0.209", features = ["derive"] } -serde-aux = "4.5.0" -serde-constant = "0.1.0" -serde_json = "1.0.127" -tokio = { version = "1.39.3", features = ["macros", "rt-multi-thread", "sync"] } -tokio-stream = { version = "0.1.15", features = ["sync"] } -tower-http = { version = "0.5.2", features = ["cors", "limit"] } -tracing = "0.1.40" -tracing-subscriber = "0.3.18" -uuid = { version = "1.10.0", features = ["serde", "v4"] } +anyhow = "1" +bitflags = "2" +bitflags_serde_shim = "0.2" +ed25519-dalek = "2.1" +hex = { version = "0.4", features = ["serde"] } +html-escape = "0.2" +rand_core = "0.6" +rusqlite = { version = "0.32", optional = true } +serde = { version = "1", features = ["derive"] } +serde_json = "1" +uuid = { version = "1", features = ["serde"] } [dev-dependencies] syn = { version = "2.0.76", features = ["full", "visit"] } - -[workspace] -members = [ "./blahctl" ] diff --git a/blahctl/Cargo.toml b/blahctl/Cargo.toml index ec58ab3..cbe5d36 100644 --- a/blahctl/Cargo.toml +++ b/blahctl/Cargo.toml @@ -4,14 +4,13 @@ version = "0.1.0" edition = "2021" [dependencies] -anyhow = "1.0.86" -bitflags = "2.6.0" -blah.path = ".." -clap = { version = "4.5.16", features = ["derive"] } -ed25519-dalek = { version = "2.1.1", features = ["pkcs8", "pem", "rand_core"] } +anyhow = "1" +clap = { version = "4", features = ["derive"] } +ed25519-dalek = { version = "2", features = ["pkcs8", "pem", "rand_core"] } hex = "0.4" -rand = "0.8.5" -reqwest = { version = "0.12.7", features = ["json"] } -rusqlite = "0.32.1" -tokio = { version = "1.39.3", features = ["rt", "macros"] } -uuid = "1.10.0" +rand = "0.8" +reqwest = { version = "0.12", features = ["json"] } +rusqlite = "0.32" +tokio = { version = "1", features = ["rt", "macros"] } + +blah = { path = "..", features = ["rusqlite"] } diff --git a/blahctl/src/main.rs b/blahctl/src/main.rs index 2f6ed58..3ae7957 100644 --- a/blahctl/src/main.rs +++ b/blahctl/src/main.rs @@ -3,11 +3,12 @@ use std::path::{Path, PathBuf}; use std::{fs, io}; use anyhow::{Context, Result}; -use bitflags::Flags; +use blah::bitflags; use blah::types::{ ChatPayload, CreateRoomPayload, MemberPermission, RichText, RoomAttrs, RoomMember, RoomMemberList, ServerPermission, UserKey, WithSig, }; +use blah::uuid::Uuid; use ed25519_dalek::pkcs8::spki::der::pem::LineEnding; use ed25519_dalek::pkcs8::{DecodePrivateKey, DecodePublicKey, EncodePrivateKey, EncodePublicKey}; use ed25519_dalek::{SigningKey, VerifyingKey, PUBLIC_KEY_LENGTH}; @@ -15,7 +16,6 @@ use rand::rngs::OsRng; use reqwest::Url; use rusqlite::{named_params, Connection}; use tokio::runtime::Runtime; -use uuid::Uuid; /// NB. Sync with docs of [`User::url`]. const KEY_URL_SUBPATH: &str = "/.well-known/blah/key"; @@ -66,7 +66,7 @@ enum DbCommand { }, } -fn flag_parser(s: &str) -> clap::error::Result { +fn flag_parser(s: &str) -> clap::error::Result { bitflags::parser::from_str_strict(s) .map_err(|_| clap::Error::new(clap::error::ErrorKind::InvalidValue)) } @@ -142,7 +142,7 @@ impl User { } } -static INIT_SQL: &str = include_str!("../../init.sql"); +static INIT_SQL: &str = include_str!("../../blahd/init.sql"); fn main() -> Result<()> { let cli = ::parse(); diff --git a/blahd/Cargo.toml b/blahd/Cargo.toml new file mode 100644 index 0000000..510fbaf --- /dev/null +++ b/blahd/Cargo.toml @@ -0,0 +1,26 @@ +[package] +name = "blahd" +version = "0.0.0" +edition = "2021" + +[dependencies] +anyhow = "1" +axum = { version = "0.7", features = ["tokio"] } +clap = { version = "4", features = ["derive"] } +ed25519-dalek = "2" +futures-util = "0.3" +hex = { version = "0.4", features = ["serde"] } +humantime = "2" +rusqlite = { version = "0.32", features = ["uuid"] } +sd-notify = "0.4" +serde = { version = "1", features = ["derive"] } +serde-aux = "4" +serde_json = "1" +tokio = { version = "1", features = ["macros", "rt-multi-thread", "sync"] } +tokio-stream = { version = "0.1", features = ["sync"] } +tower-http = { version = "0.5", features = ["cors", "limit"] } +tracing = "0.1" +tracing-subscriber = "0.3" +uuid = { version = "1", features = ["v4"] } + +blah = { path = "..", features = ["rusqlite"] } diff --git a/docs/webapi.yaml b/blahd/docs/webapi.yaml similarity index 100% rename from docs/webapi.yaml rename to blahd/docs/webapi.yaml diff --git a/init.sql b/blahd/init.sql similarity index 100% rename from init.sql rename to blahd/init.sql diff --git a/src/main.rs b/blahd/src/main.rs similarity index 100% rename from src/main.rs rename to blahd/src/main.rs diff --git a/src/lib.rs b/src/lib.rs index cd40856..308ea54 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1 +1,6 @@ +// Re-export of public dependencies. +pub use bitflags; +pub use ed25519_dalek; +pub use uuid; + pub mod types; diff --git a/src/types.rs b/src/types.rs index e5def22..d551767 100644 --- a/src/types.rs +++ b/src/types.rs @@ -367,6 +367,7 @@ impl_serde_for_bitflags!(ServerPermission); impl_serde_for_bitflags!(MemberPermission); impl_serde_for_bitflags!(RoomAttrs); +#[cfg(feature = "rusqlite")] mod sql_impl { use rusqlite::types::{FromSql, FromSqlError, FromSqlResult, ToSqlOutput, ValueRef}; use rusqlite::{Result, ToSql};