Crate big_decimal_byte_string_encoder

Source
Expand description

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.

§Examples

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);

Enums§

NumericEncoderError
Errors that can occur during encoding or decoding.

Functions§

decode_bigquery_bytes_to_bigdecimal
Decodes a byte string to a BigDecimal value.
encode_bigdecimal_to_bigquery_bytes
Encodes a BigDecimal value to a byte string compatible with BigQuery’s NUMERIC type.