Crates.io | big-decimal-byte-string-encoder |
lib.rs | big-decimal-byte-string-encoder |
version | 0.1.0 |
source | src |
created_at | 2024-07-31 11:54:21.130634 |
updated_at | 2024-07-31 11:54:21.130634 |
description | A Rust implementation of Google BigQuery's BigDecimalByteStringEncoder |
homepage | |
repository | https://github.com/SINTEF/rust-big-decimal-byte-string-encoder |
max_upload_size | |
id | 1320857 |
size | 26,563 |
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.
BigDecimal
values to BigQuery NUMERIC bytes.BigDecimal
values.Add this to your Cargo.toml
:
[dependencies]
big-decimal-byte-string-encoder = "0.1.0"
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);
For detailed API documentation, please visit docs.rs.
This project is licensed under the Apache License, Version 2.0. See the LICENSE file for details.
This implementation is inspired by and ported from Google's BigQuery Write API. For more information, see the BigQuery Write API documentation.
Contributions are welcome! Please feel free to submit a Pull Request.