Skip to content

Commit 0fe6645

Browse files
authored
chore: reduce required dependencies for cocoindex_utils crate (#1318)
1 parent cebe1de commit 0fe6645

File tree

5 files changed

+34
-11
lines changed

5 files changed

+34
-11
lines changed

Cargo.lock

Lines changed: 0 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

rust/cocoindex/Cargo.toml

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,14 @@ default = ["legacy-states-v0"]
1414
legacy-states-v0 = []
1515

1616
[dependencies]
17-
cocoindex_utils = { path = "../utils" }
17+
cocoindex_utils = { path = "../utils", features = [
18+
"bytes_decode",
19+
"reqwest",
20+
"openai",
21+
"neo4rs",
22+
"sqlx",
23+
"yaml",
24+
] }
1825
cocoindex_py_utils = { path = "../py_utils" }
1926

2027
pyo3 = { workspace = true }

rust/utils/Cargo.toml

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -17,16 +17,25 @@ tokio = { workspace = true }
1717
tokio-util = { workspace = true }
1818
futures = { workspace = true }
1919
blake2 = { workspace = true }
20-
reqwest = { workspace = true }
21-
async-openai = { workspace = true }
22-
neo4rs = { workspace = true }
23-
sqlx = { workspace = true }
24-
encoding_rs = { workspace = true }
25-
regex = { workspace = true }
2620
itertools = { workspace = true }
2721
indexmap = { workspace = true }
2822
hex = { workspace = true }
2923
serde_path_to_error = { workspace = true }
3024
rand = { workspace = true }
31-
yaml-rust2 = { workspace = true }
3225
indenter = { workspace = true }
26+
27+
encoding_rs = { workspace = true, optional = true }
28+
reqwest = { workspace = true, optional = true }
29+
async-openai = { workspace = true, optional = true }
30+
neo4rs = { workspace = true, optional = true }
31+
sqlx = { workspace = true, optional = true }
32+
yaml-rust2 = { workspace = true, optional = true }
33+
34+
[features]
35+
default = []
36+
reqwest = ["dep:reqwest"]
37+
openai = ["dep:async-openai", "reqwest"]
38+
neo4rs = ["dep:neo4rs"]
39+
sqlx = ["dep:sqlx"]
40+
yaml = ["dep:yaml-rust2"]
41+
bytes_decode = ["dep:encoding_rs"]

rust/utils/src/lib.rs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,17 @@
11
pub mod batching;
2-
pub mod bytes_decode;
32
pub mod concur_control;
43
pub mod db;
54
pub mod deser;
65
pub mod error;
76
pub mod fingerprint;
8-
pub mod http;
97
pub mod immutable;
108
pub mod retryable;
9+
10+
#[cfg(feature = "bytes_decode")]
11+
pub mod bytes_decode;
12+
#[cfg(feature = "reqwest")]
13+
pub mod http;
14+
#[cfg(feature = "sqlx")]
1115
pub mod str_sanitize;
16+
#[cfg(feature = "yaml")]
1217
pub mod yaml_ser;

rust/utils/src/retryable.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,13 +33,15 @@ impl IsRetryable for Error {
3333
}
3434
}
3535

36+
#[cfg(feature = "reqwest")]
3637
impl IsRetryable for reqwest::Error {
3738
fn is_retryable(&self) -> bool {
3839
self.status() == Some(reqwest::StatusCode::TOO_MANY_REQUESTS)
3940
}
4041
}
4142

4243
// OpenAI errors - retryable if the underlying reqwest error is retryable
44+
#[cfg(feature = "openai")]
4345
impl IsRetryable for async_openai::error::OpenAIError {
4446
fn is_retryable(&self) -> bool {
4547
match self {
@@ -50,6 +52,7 @@ impl IsRetryable for async_openai::error::OpenAIError {
5052
}
5153

5254
// Neo4j errors - retryable on connection errors and transient errors
55+
#[cfg(feature = "neo4rs")]
5356
impl IsRetryable for neo4rs::Error {
5457
fn is_retryable(&self) -> bool {
5558
match self {

0 commit comments

Comments
 (0)