GithubHelp home page GithubHelp logo

tzconnectberlin / rust-pg_bigdecimal Goto Github PK

View Code? Open in Web Editor NEW
5.0 0.0 3.0 98 KB

A Rust native datatype for Postgres' Numeric type, to be used with Rust's "Postgres" library.

License: MIT License

Rust 97.81% Shell 2.19%
rust postgres numeric

rust-pg_bigdecimal's Introduction

rust-pg_bigdecimal

A Rust datatype implementation for the Postgres Numeric type (ie the types listed in https://www.postgresql.org/docs/13/datatype-numeric.html under "decimal"/"numeric"), to be used with Rust's "Postgres" library. The full spectrum of Postgres' Numeric value range is supported.

This small Rust package has been created because currently the main "Postgres" library (https://docs.rs/postgres/0.19.1/postgres/index.html) does not provide a native datatype to read/write Numeric values.

We only implement the wire logic of Postgres' Numeric datatype. We didn't rewrite the whole logic of big number manipulation, rather we let that logic be implemented by the already popular BigDecimal package (https://docs.rs/bigdecimal/0.3.0/bigdecimal/).

Specifically, our new Rust datatype PgNumeric is simply an Optional BigDecimal. With None representing the Postgres Numeric value NaN, and all Some(..) representing Postgres Numeric numbers.

Listed on crates.io here: https://crates.io/crates/pg_bigdecimal.

Comparisons between similar packages

  • https://crates.io/crates/rust-decimal provides a rust native type, however it's represented as a 96 bit integer number + scaling bits + 1 sign bit. This means that "only" (quoting only here because it is still a large integer space) a small part of Postgres' Numeric values can be translated. In our case it was not sufficient.

rust-pg_bigdecimal's People

Contributors

dependabot[bot] avatar johnsnewby avatar rklompuu avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.