diff --git a/Cargo.toml b/Cargo.toml index 3ca0306..0ba1e3f 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -4,6 +4,17 @@ version = "0.1.0" edition = "2021" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html +[workspace] +members = [".", "bearmark-ql"] + +[workspace.dependencies] +serde = { version = "1.0.203", features = ["derive"] } +# logging +tracing = "0.1.40" +tracing-appender = "0.2.3" +tracing-subscriber = { version = "0.3.18", features = ["env-filter"] } +# initialization +ctor = "0.2.8" [dependencies] rocket = { version = "0.5.1", features = ["json"] } @@ -12,32 +23,32 @@ rocket_db_pools = "0.2.0" # database diesel = { version = "2.2.0", features = ["postgres", "time"] } diesel-async = { version = "0.5.0", features = [ - "async-connection-wrapper", - "postgres", - "deadpool", + "async-connection-wrapper", + "postgres", + "deadpool", ] } diesel_migrations = { version = "2.2.0", features = ["postgres"] } openssl-sys = { version = "0.9.102", features = [ - "vendored", + "vendored", ] } # static linking required pq-sys = { version = "0.6.1", features = ["bundled"] } # static linking required ################## # other utilities ################## +serde.workspace = true rand = "0.8.5" itertools = "0.13.0" -serde = { version = "1.0.203", features = ["derive"] } time = { version = "0.3.36", features = ["local-offset", "macros", "serde"] } percent-encoding = "2.3.1" # search enhancement -pratt-gen = "0.1.0" +bearmark-ql = { path = "bearmark-ql" } # read settings from the dotenv file dotenvy = "0.15.7" # logging -tracing = "0.1.40" -tracing-appender = "0.2.3" -tracing-subscriber = { version = "0.3.18", features = ["env-filter"] } +tracing.workspace = true +tracing-appender.workspace = true +tracing-subscriber.workspace = true # async runtime tokio = { version = "1.38.0", features = ["rt", "macros", "sync"] } futures = "0.3.30" @@ -47,7 +58,7 @@ thiserror = "1.0.63" [dev-dependencies] # setup for tests -ctor = "0.2.8" +ctor.workspace = true [[bin]] name = "serve" diff --git a/bearmark-ql/Cargo.toml b/bearmark-ql/Cargo.toml new file mode 100644 index 0000000..ec55a62 --- /dev/null +++ b/bearmark-ql/Cargo.toml @@ -0,0 +1,21 @@ +[package] +name = "bearmark-ql" +version = "0.1.0" +edition = "2021" + +[dependencies] +pratt-gen = "0.1.0" +serde.workspace = true + +# logging +tracing.workspace = true + +[dev-dependencies] +# setup for tests +ctor.workspace = true +# logging +tracing-appender.workspace = true +tracing-subscriber.workspace = true + +[lints.rust] +unexpected_cfgs = { level = "warn", check-cfg = ['cfg(tarpaulin_include)'] } diff --git a/src/utils/search.rs b/bearmark-ql/src/lib.rs similarity index 99% rename from src/utils/search.rs rename to bearmark-ql/src/lib.rs index 348d9de..7998068 100644 --- a/src/utils/search.rs +++ b/bearmark-ql/src/lib.rs @@ -1,6 +1,9 @@ +use std::fmt::{Debug, Display}; + use pratt_gen::*; use serde::Serializer; -use std::fmt::{Debug, Display}; + +pub use pratt_gen::{parse, Arena, Source}; #[derive(Debug, Clone, Copy, ParserImpl, Space)] pub enum Query<'a> { diff --git a/src/db/search.rs b/src/db/search.rs index 7922c3f..e23e477 100644 --- a/src/db/search.rs +++ b/src/db/search.rs @@ -3,16 +3,16 @@ use diesel::pg::Pg; use diesel::prelude::*; use diesel::sql_types::Bool; use diesel_async::{AsyncPgConnection as Connection, RunQueryDsl}; -use pratt_gen::{parse, Arena, Source}; use tracing::{debug, warn}; use super::bookmark::Bookmark; use super::folder::Folder; use super::tag::Tag; use crate::db::schema; -use crate::utils::search; use crate::utils::{BearQLError, CommonError}; +use bearmark_ql::{self as search, parse, Arena, Source}; + fn parse_query<'a>( raw: &'a str, out_arena: &'a Arena, diff --git a/src/utils/mod.rs b/src/utils/mod.rs index db44cee..3c413b0 100644 --- a/src/utils/mod.rs +++ b/src/utils/mod.rs @@ -1,6 +1,5 @@ pub mod logging; pub mod rand; -pub mod search; mod errors; pub use errors::{BearQLError, CommonError, DatabaseError};