20 releases
new 0.0.23 | Jan 28, 2025 |
---|---|
0.0.22 | Jan 25, 2025 |
0.0.16 | Dec 28, 2024 |
0.0.13 | Nov 28, 2024 |
0.0.6 | Aug 29, 2024 |
#386 in Magic Beans
617 downloads per month
Used in 6 crates
(3 directly)
31KB
435 lines
📝 About
The DataParser
struct provides functionality for encoding and decoding data through compression and serialization. It offers flexibility in choosing compression strategies and serialization formats, allowing for optimization of memory usage and I/O bandwidth. This utility is particularly useful when dealing with large datasets or when efficient data transfer is crucial.
🛠️ Usage
This library is intended for internal use within the Fuel Data Systems project. This is an example of usage outside of this crate within the project:
use fuel_data_parser::{DataEncoder, DataParser, SerializationType, DataParserError};
use serde::{Serialize, Deserialize};
#[derive(Debug, Clone, Serialize, Deserialize)]
struct YourDataType {
// Your data fields here
}
impl DataEncoder for YourDataType {
type Err = DataParserError;
}
async fn example_usage() -> Result<(), Box<dyn std::error::Error>> {
let parser = DataParser::default()
.with_serialization_type(SerializationType::Bincode);
// Encoding data
let data = YourDataType { /* ... */ };
let encoded = parser.encode(&data).await?;
// Decoding data
let decoded: YourDataType = parser.decode(&encoded).await?;
Ok(())
}
🏎️ Benchmarks
To run the benchmarks and measure performance of different serialization and compression strategies:
cargo bench -p data-parser
[!INFO] The benchmarks are located in the
../../benches
folder.
🤝 Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
For more information on contributing, please see the CONTRIBUTING.md file in the root of the repository.
📜 License
This repo is licensed under the Apache-2.0
license. See LICENSE
for more information.
Dependencies
~3–11MB
~131K SLoC