Skip to content

Commit

Permalink
Merge pull request #13 from linw1995/refactor/bearmark-ql
Browse files Browse the repository at this point in the history
Add new package bearmark-ql
  • Loading branch information
linw1995 authored Sep 24, 2024
2 parents 7783c60 + c3c0989 commit 4d6523d
Show file tree
Hide file tree
Showing 5 changed files with 48 additions and 14 deletions.
31 changes: 21 additions & 10 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"] }
Expand All @@ -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"
Expand All @@ -47,7 +58,7 @@ thiserror = "1.0.63"

[dev-dependencies]
# setup for tests
ctor = "0.2.8"
ctor.workspace = true

[[bin]]
name = "serve"
Expand Down
21 changes: 21 additions & 0 deletions bearmark-ql/Cargo.toml
Original file line number Diff line number Diff line change
@@ -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)'] }
5 changes: 4 additions & 1 deletion src/utils/search.rs → bearmark-ql/src/lib.rs
Original file line number Diff line number Diff line change
@@ -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> {
Expand Down
4 changes: 2 additions & 2 deletions src/db/search.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
1 change: 0 additions & 1 deletion src/utils/mod.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
pub mod logging;
pub mod rand;
pub mod search;

mod errors;
pub use errors::{BearQLError, CommonError, DatabaseError};

0 comments on commit 4d6523d

Please sign in to comment.