rustler_bigint 0.1.0

Handle Erlang's arbitrarily-sized integers
Documentation
  • Coverage
  • 50%
    2 out of 4 items documented2 out of 3 items with examples
  • Size
  • Source code size: 23.3 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 2.17 MB This is the summed size of all files generated by rustdoc for all configured targets
  • Ø build duration
  • this release: 22s Average build duration of successful builds.
  • all releases: 22s Average build duration of successful builds in releases after 2024-10-23.
  • Links
  • rusterlium/rustler
    4735 236 36
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • thomas9911 evnu

Rustler BigInt

Documentation Build Status Crates.io package version

rustler_bigint provides support for Erlang's arbitrarily-sized integers.

Installation

Add this to Cargo.toml:

[dependencies]
rustler_bigint = { version = "0.1" }

Example

Lets assume that we need to handle integers of variable size. Some might fit into Rust's i64, but others might not. For example:

large = Bitwise.bsl(2, 65) # This does not fit into i64, it is an Erlang big integer

In Rust, we can use rustler_bigint::BigInt to pass integer values of different sizes into a NIF. The type rustler_bigint::BigInt is a newtype wrapping num_bigint::BigInt and implements std::ops::Deref, so functions from num_bigint::BigInt can be called directly.

/// Simply echo `large` back to the caller.
#[rustler::nif]
pub fn handle_large(large: rustler_bigint::BigInt) -> NifResult<rustler_bigint::BigInt> {
  Ok(large)
}