This is an automated email from the ASF dual-hosted git repository.
mgrigorov pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/avro-rs.git
The following commit(s) were added to refs/heads/main by this push:
new b7cfdc6 chore: Get rid of anyhow as a dev-dependency (#427)
b7cfdc6 is described below
commit b7cfdc6d6e1a23efe75fe6891134d0a40b1f1921
Author: Martin Grigorov <[email protected]>
AuthorDate: Fri Jan 23 13:48:15 2026 +0200
chore: Get rid of anyhow as a dev-dependency (#427)
Reason: Less dependencies, faster build.
---
Cargo.lock | 7 -------
avro/Cargo.toml | 1 -
avro/benches/serde.rs | 30 +++++++++++++++++-------------
avro/benches/single.rs | 4 ++--
avro/examples/specific_single_object.rs | 2 +-
avro/examples/to_value.rs | 2 +-
avro/src/duration.rs | 3 +--
7 files changed, 22 insertions(+), 27 deletions(-)
diff --git a/Cargo.lock b/Cargo.lock
index bb1202d..249241c 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -47,17 +47,10 @@ version = "1.0.13"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5192cca8006f1fd4f7237516f40fa183bb07f8fbdfedaa0036de5ea9b0b45e78"
-[[package]]
-name = "anyhow"
-version = "1.0.100"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "a23eb6b1614318a8071c9b2521f36b424b2c83db5eb3a0fead4a6c0809af6e61"
-
[[package]]
name = "apache-avro"
version = "0.22.0"
dependencies = [
- "anyhow",
"apache-avro-derive",
"apache-avro-test-helper",
"bigdecimal",
diff --git a/avro/Cargo.toml b/avro/Cargo.toml
index a71cc64..2cc9229 100644
--- a/avro/Cargo.toml
+++ b/avro/Cargo.toml
@@ -82,7 +82,6 @@ quad-rand = { default-features = false, version = "0.2.3" }
rand = { default-features = false, version = "0.9.2", features = ["default"] }
[dev-dependencies]
-anyhow = { default-features = false, version = "1.0.100", features = ["std"] }
apache-avro-test-helper = { default-features = false, version = "0.22.0", path
= "../avro_test_helper" }
criterion = { default-features = false, version = "0.8.1" }
hex-literal = { default-features = false, version = "1.1.0" }
diff --git a/avro/benches/serde.rs b/avro/benches/serde.rs
index 471c082..fad858b 100644
--- a/avro/benches/serde.rs
+++ b/avro/benches/serde.rs
@@ -162,7 +162,7 @@ const RAW_ADDRESS_SCHEMA: &str = r#"
}
"#;
-fn make_small_record() -> anyhow::Result<(Schema, Value)> {
+fn make_small_record() -> Result<(Schema, Value), Box<dyn std::error::Error>> {
let small_schema = Schema::parse_str(RAW_SMALL_SCHEMA)?;
let small_record = {
let mut small_record = Record::new(&small_schema).unwrap();
@@ -172,7 +172,7 @@ fn make_small_record() -> anyhow::Result<(Schema, Value)> {
Ok((small_schema, small_record))
}
-fn make_small_record_ser() -> anyhow::Result<(Schema, SmallRecord)> {
+fn make_small_record_ser() -> Result<(Schema, SmallRecord), Box<dyn
std::error::Error>> {
let small_schema = Schema::parse_str(RAW_SMALL_SCHEMA)?;
let small_record = SmallRecord {
field: String::from("foo"),
@@ -180,7 +180,7 @@ fn make_small_record_ser() -> anyhow::Result<(Schema,
SmallRecord)> {
Ok((small_schema, small_record))
}
-fn make_big_record() -> anyhow::Result<(Schema, Value)> {
+fn make_big_record() -> Result<(Schema, Value), Box<dyn std::error::Error>> {
let big_schema = Schema::parse_str(RAW_BIG_SCHEMA)?;
let address_schema = Schema::parse_str(RAW_ADDRESS_SCHEMA)?;
let mut address = Record::new(&address_schema).unwrap();
@@ -212,7 +212,7 @@ fn make_big_record() -> anyhow::Result<(Schema, Value)> {
Ok((big_schema, big_record))
}
-fn make_big_record_ser() -> anyhow::Result<(Schema, BigRecord)> {
+fn make_big_record_ser() -> Result<(Schema, BigRecord), Box<dyn
std::error::Error>> {
let big_schema = Schema::parse_str(RAW_BIG_SCHEMA)?;
let big_record = BigRecord {
username: Some(String::from("username")),
@@ -250,7 +250,7 @@ fn write_ser<T: Serialize>(schema: &Schema, records: &[T])
-> AvroResult<Vec<u8>
writer.into_inner()
}
-fn read(schema: &Schema, bytes: &[u8]) -> anyhow::Result<()> {
+fn read(schema: &Schema, bytes: &[u8]) -> Result<(), Box<dyn
std::error::Error>> {
let reader = Reader::with_schema(schema, bytes)?;
for record in reader {
@@ -259,7 +259,7 @@ fn read(schema: &Schema, bytes: &[u8]) ->
anyhow::Result<()> {
Ok(())
}
-fn read_schemaless(bytes: &[u8]) -> anyhow::Result<()> {
+fn read_schemaless(bytes: &[u8]) -> Result<(), Box<dyn std::error::Error>> {
let reader = Reader::new(bytes)?;
for record in reader {
@@ -270,10 +270,10 @@ fn read_schemaless(bytes: &[u8]) -> anyhow::Result<()> {
fn bench_write(
c: &mut Criterion,
- make_record: impl Fn() -> anyhow::Result<(Schema, Value)>,
+ make_record: impl Fn() -> Result<(Schema, Value), Box<dyn
std::error::Error>>,
n_records: usize,
name: &str,
-) -> anyhow::Result<()> {
+) -> Result<(), Box<dyn std::error::Error>> {
let (schema, record) = make_record()?;
let records = make_records(record, n_records);
c.bench_function(name, |b| b.iter(|| write(&schema, &records)));
@@ -282,10 +282,10 @@ fn bench_write(
fn bench_write_ser<T: Serialize + Clone>(
c: &mut Criterion,
- make_record: impl Fn() -> anyhow::Result<(Schema, T)>,
+ make_record: impl Fn() -> Result<(Schema, T), Box<dyn std::error::Error>>,
n_records: usize,
name: &str,
-) -> anyhow::Result<()> {
+) -> Result<(), Box<dyn std::error::Error>> {
let (schema, record) = make_record()?;
let records = make_records_ser(record, n_records);
c.bench_function(name, |b| b.iter(|| write_ser(&schema, &records)));
@@ -294,10 +294,10 @@ fn bench_write_ser<T: Serialize + Clone>(
fn bench_read(
c: &mut Criterion,
- make_record: impl Fn() -> anyhow::Result<(Schema, Value)>,
+ make_record: impl Fn() -> Result<(Schema, Value), Box<dyn
std::error::Error>>,
n_records: usize,
name: &str,
-) -> anyhow::Result<()> {
+) -> Result<(), Box<dyn std::error::Error>> {
let (schema, record) = make_record()?;
let records = make_records(record, n_records);
let bytes = write(&schema, &records).unwrap();
@@ -305,7 +305,11 @@ fn bench_read(
Ok(())
}
-fn bench_from_file(c: &mut Criterion, file_path: &str, name: &str) ->
anyhow::Result<()> {
+fn bench_from_file(
+ c: &mut Criterion,
+ file_path: &str,
+ name: &str,
+) -> Result<(), Box<dyn std::error::Error>> {
let bytes = std::fs::read(file_path)?;
c.bench_function(name, |b| b.iter(|| read_schemaless(&bytes)));
Ok(())
diff --git a/avro/benches/single.rs b/avro/benches/single.rs
index 48a06ca..05d8453 100644
--- a/avro/benches/single.rs
+++ b/avro/benches/single.rs
@@ -137,7 +137,7 @@ const RAW_ADDRESS_SCHEMA: &str = r#"
}
"#;
-fn make_small_record() -> anyhow::Result<(Schema, Value)> {
+fn make_small_record() -> Result<(Schema, Value), Box<dyn std::error::Error>> {
let small_schema = Schema::parse_str(RAW_SMALL_SCHEMA)?;
let small_record = {
let mut small_record = Record::new(&small_schema).unwrap();
@@ -148,7 +148,7 @@ fn make_small_record() -> anyhow::Result<(Schema, Value)> {
Ok((small_schema, small_record))
}
-fn make_big_record() -> anyhow::Result<(Schema, Value)> {
+fn make_big_record() -> Result<(Schema, Value), Box<dyn std::error::Error>> {
let big_schema = Schema::parse_str(RAW_BIG_SCHEMA)?;
let address_schema = Schema::parse_str(RAW_ADDRESS_SCHEMA)?;
let mut address = Record::new(&address_schema).unwrap();
diff --git a/avro/examples/specific_single_object.rs
b/avro/examples/specific_single_object.rs
index 15ab480..1ade06f 100644
--- a/avro/examples/specific_single_object.rs
+++ b/avro/examples/specific_single_object.rs
@@ -24,7 +24,7 @@ struct Test {
b: String,
}
-fn main() -> anyhow::Result<()> {
+fn main() -> Result<(), Box<dyn std::error::Error>> {
let mut buffer: Vec<u8> = Vec::new();
let test = Test {
a: 27,
diff --git a/avro/examples/to_value.rs b/avro/examples/to_value.rs
index 4a78383..e4e38b4 100644
--- a/avro/examples/to_value.rs
+++ b/avro/examples/to_value.rs
@@ -21,7 +21,7 @@ struct Test {
b: &'static str,
}
-fn main() -> anyhow::Result<()> {
+fn main() -> Result<(), Box<dyn std::error::Error>> {
let test = Test { a: 27, b: "foo" };
let value = apache_avro::to_value(test)?;
println!("{value:?}");
diff --git a/avro/src/duration.rs b/avro/src/duration.rs
index c229171..cf24bc0 100644
--- a/avro/src/duration.rs
+++ b/avro/src/duration.rs
@@ -207,7 +207,6 @@ impl<'de> Deserialize<'de> for Duration {
mod tests {
use super::*;
use crate::types::Value;
- use anyhow::anyhow;
use apache_avro_test_helper::TestResult;
#[test]
@@ -230,7 +229,7 @@ mod tests {
assert_eq!(b, vec![7, 0, 0, 0, 4, 0, 0, 0, 45, 0, 0, 0]);
}
_ => {
- Err(anyhow!("Expected a Bytes value but got {ser_val:?}"))?;
+ Err(format!("Expected a Bytes value but got {ser_val:?}"))?;
}
}
Ok(())