Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/sintef/rust-big-decimal-byte-string-encoder
A Rust implementation of Google BigQuery's BigDecimalByteStringEncoder
https://github.com/sintef/rust-big-decimal-byte-string-encoder
Last synced: about 2 months ago
JSON representation
A Rust implementation of Google BigQuery's BigDecimalByteStringEncoder
- Host: GitHub
- URL: https://github.com/sintef/rust-big-decimal-byte-string-encoder
- Owner: SINTEF
- License: apache-2.0
- Created: 2024-07-31T11:49:27.000Z (5 months ago)
- Default Branch: main
- Last Pushed: 2024-07-31T11:54:32.000Z (5 months ago)
- Last Synced: 2024-10-06T10:18:25.329Z (3 months ago)
- Language: Rust
- Size: 9.77 KB
- Stars: 0
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# big-decimal-byte-string-encoder
[![Crates.io](https://img.shields.io/crates/v/big-decimal-byte-string-encoder.svg)](https://crates.io/crates/big-decimal-byte-string-encoder)
[![Documentation](https://docs.rs/big-decimal-byte-string-encoder/badge.svg)](https://docs.rs/big-decimal-byte-string-encoder)
[![License](https://img.shields.io/badge/license-Apache--2.0-blue.svg)](LICENSE)A Rust implementation of Google BigQuery's BigDecimalByteStringEncoder for the NUMERIC data type.
This crate provides functionality to encode and decode BigDecimal values to and from byte strings compatible with BigQuery's NUMERIC type, as used in the BigQuery Write API.
It goes nicely with [gcp-bigquery-client](https://github.com/lquerel/gcp-bigquery-client).
## Features
- Encode `BigDecimal` values to BigQuery NUMERIC bytes.
- Decode BigQuery NUMERIC bytes back to `BigDecimal` values.## Installation
Add this to your `Cargo.toml`:
```toml
[dependencies]
big-decimal-byte-string-encoder = "0.1.0"
```## Usage
```rust
use bigdecimal::BigDecimal;
use big_decimal_byte_string_encoder::{decode_bigquery_bytes_to_bigdecimal, encode_bigdecimal_to_bigquery_bytes};
use std::str::FromStr;let decimal = BigDecimal::from_str("123.456").unwrap();
let encoded = encode_bigdecimal_to_bigquery_bytes(&decimal).unwrap();
let decoded = decode_bigquery_bytes_to_bigdecimal(&encoded).unwrap();
assert_eq!(decimal, decoded);
```## API Documentation
For detailed API documentation, please visit [docs.rs](https://docs.rs/big-decimal-byte-string-encoder).
## License
This project is licensed under the Apache License, Version 2.0. See the LICENSE file for details.
## Acknowledgments
This implementation is inspired by and ported from Google's BigQuery Write API. For more information, see the [BigQuery Write API documentation](https://cloud.google.com/bigquery/docs/write-api#data_type_conversions).
## Contributing
Contributions are welcome! Please feel free to submit a Pull Request.