pub struct BigInt {
    pub sign_bit: bool,
    pub words: Vec<u64>,
}
Expand description

https://nodejs.org/api/n-api.html#napi_create_bigint_words The resulting BigInt is calculated as: (–1)^sign_bit (words[0] × (2^64)^0 + words[1] × (2^64)^1 + …)

Fields§

§sign_bit: bool

true for negative numbers

§words: Vec<u64>

Implementations§

source§

impl BigInt

source

pub fn get_u64(&self) -> (bool, u64, bool)

(signed, value, lossless) get the first word of the BigInt as u64 return true in the last element of tuple if the value is lossless or the value is truncated

source

pub fn get_i64(&self) -> (i64, bool)

(value, lossless) get the first word of the BigInt as i64 return true if the value is lossless or the value is truncated

source

pub fn get_i128(&self) -> (i128, bool)

(value, lossless) get the first two words of the BigInt as i128 return true if the value is lossless or the value is truncated

source

pub fn get_u128(&self) -> (bool, u128, bool)

(signed, value, lossless) get the first two words of the BigInt as u128 return true if the value is lossless or the value is truncated

Trait Implementations§

source§

impl Clone for BigInt

source§

fn clone(&self) -> BigInt

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl Debug for BigInt

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl From<i128> for BigInt

source§

fn from(val: i128) -> Self

Converts to this type from the input type.
source§

impl From<i64> for BigInt

source§

fn from(val: i64) -> Self

Converts to this type from the input type.
source§

impl From<u128> for BigInt

source§

fn from(val: u128) -> Self

Converts to this type from the input type.
source§

impl From<u64> for BigInt

source§

fn from(val: u64) -> Self

Converts to this type from the input type.
source§

impl FromNapiValue for BigInt

source§

unsafe fn from_napi_value(env: napi_env, napi_val: napi_value) -> Result<Self>

Safety Read more
source§

fn from_unknown(value: JsUnknown) -> Result<Self>

source§

impl ToNapiValue for BigInt

source§

unsafe fn to_napi_value(env: napi_env, val: Self) -> Result<napi_value>

Safety Read more
source§

impl TypeName for BigInt

source§

impl ValidateNapiValue for BigInt

source§

unsafe fn validate(env: napi_env, napi_val: napi_value) -> Result<napi_value>

Safety Read more

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

const: unstable · source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere T: ?Sized,

const: unstable · source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

const: unstable · source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for Twhere U: From<T>,

const: unstable · source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> JsValuesTupleIntoVec for Twhere T: ToNapiValue,

source§

impl<T> ToOwned for Twhere T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T, U> TryFrom<U> for Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
const: unstable · source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for Twhere U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
const: unstable · source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.