Skip to main content

NeoInteger

Struct NeoInteger 

Source
pub struct NeoInteger(/* private fields */);
Expand description

Neo N3 Integer type (arbitrary precision)

Implementations§

Source§

impl NeoInteger

Source

pub const MAX_BYTE_LENGTH: usize = 32

Maximum byte length of an integer the NeoVM will hold (ExecutionEngineLimits.MaxIntegerSize in C# neo-project/neo — 32 bytes / 256 bits, two’s-complement). The VM FAULTs when an operation produces an integer wider than this.

Source

pub fn new<T>(value: T) -> NeoInteger
where T: Into<BigInt>,

Source

pub fn zero() -> NeoInteger

Source

pub fn one() -> NeoInteger

Source

pub fn fits_in_neovm(&self) -> bool

Whether this value fits within the NeoVM’s 256-bit integer bound.

Host-mode arithmetic on NeoInteger is arbitrary-precision, so a computation that overflows 256 bits succeeds off-chain but FAULTs on-chain. Call this on values derived from untrusted input or unbounded accumulation to detect the divergence before it reaches the VM. Zero is one byte in num-bigint’s representation but is trivially within bounds.

Source

pub fn try_div(&self, rhs: &NeoInteger) -> Result<NeoInteger, NeoError>

Checked division: returns Err(DivisionByZero) instead of panicking (the Div operator faults on a zero divisor — on-chain that becomes a VM FAULT reverting the whole transaction). Use this in any contract path that cannot guarantee a non-zero divisor (D5).

Source

pub fn try_rem(&self, rhs: &NeoInteger) -> Result<NeoInteger, NeoError>

Checked remainder: returns Err(DivisionByZero) instead of panicking (see try_div). Matches the Rem operator’s fault-on-zero behaviour.

Source

pub fn min_i32() -> NeoInteger

Source

pub fn max_i32() -> NeoInteger

Source

pub fn as_bigint(&self) -> &BigInt

Source

pub fn to_bigint(&self) -> BigInt

Owned BigInt (clones the inner BigInt). Use this when you need to keep the value past the NeoInteger’s lifetime (e.g. pass to an API that expects BigInt by value).

Source

pub fn from_bigint(value: &BigInt) -> NeoInteger

Construct a NeoInteger from a BigInt. The From<BigInt> impl already provides this, but spelled as a method for uniformity with to_bigint and for code that has the BigInt behind a reference.

Source

pub fn try_as_i32(&self) -> Option<i32>

Convert to i32, returning None if the value is out of range. This is the safe alternative to as_i32() that doesn’t panic.

Source

pub fn try_as_u32(&self) -> Option<u32>

Convert to u32, returning None if the value is out of range. This is the safe alternative to as_u32() that doesn’t panic.

Source

pub fn try_as_i64(&self) -> Option<i64>

Convert to i64, returning None if the value is out of range.

Source

pub fn try_as_u64(&self) -> Option<u64>

Convert to u64, returning None if the value is out of range.

Source

pub fn try_into_i32(&self) -> Result<i32, NeoError>

Convert to i32, returning Result for ergonomic ? usage.

Source

pub fn try_into_u32(&self) -> Result<u32, NeoError>

Convert to u32, returning Result for ergonomic ? usage.

Source

pub fn try_into_i64(&self) -> Result<i64, NeoError>

Convert to i64, returning Result for ergonomic ? usage.

Source

pub fn try_into_u64(&self) -> Result<u64, NeoError>

Convert to u64, returning Result for ergonomic ? usage.

Source

pub fn as_i32_saturating(&self) -> i32

Convert to i32, saturating at the boundaries if the value is out of range. This never panics.

Source

pub fn as_u32_saturating(&self) -> u32

Convert to u32, saturating at the boundaries if the value is out of range. This never panics.

Source

pub fn as_i64_saturating(&self) -> i64

Convert to i64, saturating at the boundaries if the value is out of range. This never panics.

Source

pub fn as_i32(&self) -> i32

👎Deprecated since 0.1.0:

Use try_as_i32() or as_i32_saturating() explicitly

Deprecated compatibility helper that converts to i32 using saturating semantics.

Source

pub fn as_u32(&self) -> u32

👎Deprecated since 0.1.0:

Use try_as_u32() or as_u32_saturating() explicitly

Deprecated compatibility helper that converts to u32 using saturating semantics.

Source

pub fn to_i32(&self) -> Option<i32>

👎Deprecated since 0.1.0:

Use try_as_i32() instead

Deprecated: use try_as_i32() instead.

Source

pub fn to_u32(&self) -> Option<u32>

👎Deprecated since 0.1.0:

Use try_as_u32() instead

Deprecated: use try_as_u32() instead.

Source

pub fn to_i64(&self) -> Option<i64>

👎Deprecated since 0.1.0:

Use try_as_i64() instead

Deprecated: use try_as_i64() instead.

Trait Implementations§

Source§

impl Add for NeoInteger

Source§

type Output = NeoInteger

The resulting type after applying the + operator.
Source§

fn add(self, rhs: NeoInteger) -> <NeoInteger as Add>::Output

Performs the + operation. Read more
Source§

impl Add<&NeoInteger> for NeoInteger

Source§

type Output = NeoInteger

The resulting type after applying the + operator.
Source§

fn add(self, rhs: &NeoInteger) -> <NeoInteger as Add<&NeoInteger>>::Output

Performs the + operation. Read more
Source§

impl Add<&NeoInteger> for &NeoInteger

Source§

type Output = NeoInteger

The resulting type after applying the + operator.
Source§

fn add(self, rhs: &NeoInteger) -> <&NeoInteger as Add<&NeoInteger>>::Output

Performs the + operation. Read more
Source§

impl Add<NeoInteger> for &NeoInteger

Source§

type Output = NeoInteger

The resulting type after applying the + operator.
Source§

fn add(self, rhs: NeoInteger) -> <&NeoInteger as Add<NeoInteger>>::Output

Performs the + operation. Read more
Source§

impl BitAnd for NeoInteger

Source§

type Output = NeoInteger

The resulting type after applying the & operator.
Source§

fn bitand(self, rhs: NeoInteger) -> <NeoInteger as BitAnd>::Output

Performs the & operation. Read more
Source§

impl BitAnd<&NeoInteger> for NeoInteger

Source§

type Output = NeoInteger

The resulting type after applying the & operator.
Source§

fn bitand(self, rhs: &NeoInteger) -> <NeoInteger as BitAnd<&NeoInteger>>::Output

Performs the & operation. Read more
Source§

impl BitAnd<&NeoInteger> for &NeoInteger

Source§

type Output = NeoInteger

The resulting type after applying the & operator.
Source§

fn bitand( self, rhs: &NeoInteger, ) -> <&NeoInteger as BitAnd<&NeoInteger>>::Output

Performs the & operation. Read more
Source§

impl BitAnd<NeoInteger> for &NeoInteger

Source§

type Output = NeoInteger

The resulting type after applying the & operator.
Source§

fn bitand(self, rhs: NeoInteger) -> <&NeoInteger as BitAnd<NeoInteger>>::Output

Performs the & operation. Read more
Source§

impl BitOr for NeoInteger

Source§

type Output = NeoInteger

The resulting type after applying the | operator.
Source§

fn bitor(self, rhs: NeoInteger) -> <NeoInteger as BitOr>::Output

Performs the | operation. Read more
Source§

impl BitOr<&NeoInteger> for NeoInteger

Source§

type Output = NeoInteger

The resulting type after applying the | operator.
Source§

fn bitor(self, rhs: &NeoInteger) -> <NeoInteger as BitOr<&NeoInteger>>::Output

Performs the | operation. Read more
Source§

impl BitOr<&NeoInteger> for &NeoInteger

Source§

type Output = NeoInteger

The resulting type after applying the | operator.
Source§

fn bitor(self, rhs: &NeoInteger) -> <&NeoInteger as BitOr<&NeoInteger>>::Output

Performs the | operation. Read more
Source§

impl BitOr<NeoInteger> for &NeoInteger

Source§

type Output = NeoInteger

The resulting type after applying the | operator.
Source§

fn bitor(self, rhs: NeoInteger) -> <&NeoInteger as BitOr<NeoInteger>>::Output

Performs the | operation. Read more
Source§

impl BitXor for NeoInteger

Source§

type Output = NeoInteger

The resulting type after applying the ^ operator.
Source§

fn bitxor(self, rhs: NeoInteger) -> <NeoInteger as BitXor>::Output

Performs the ^ operation. Read more
Source§

impl BitXor<&NeoInteger> for NeoInteger

Source§

type Output = NeoInteger

The resulting type after applying the ^ operator.
Source§

fn bitxor(self, rhs: &NeoInteger) -> <NeoInteger as BitXor<&NeoInteger>>::Output

Performs the ^ operation. Read more
Source§

impl BitXor<&NeoInteger> for &NeoInteger

Source§

type Output = NeoInteger

The resulting type after applying the ^ operator.
Source§

fn bitxor( self, rhs: &NeoInteger, ) -> <&NeoInteger as BitXor<&NeoInteger>>::Output

Performs the ^ operation. Read more
Source§

impl BitXor<NeoInteger> for &NeoInteger

Source§

type Output = NeoInteger

The resulting type after applying the ^ operator.
Source§

fn bitxor(self, rhs: NeoInteger) -> <&NeoInteger as BitXor<NeoInteger>>::Output

Performs the ^ operation. Read more
Source§

impl Clone for NeoInteger

Source§

fn clone(&self) -> NeoInteger

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Debug for NeoInteger

Source§

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

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

impl Default for NeoInteger

Source§

fn default() -> NeoInteger

Returns the “default value” for a type. Read more
Source§

impl<'de> Deserialize<'de> for NeoInteger

Source§

fn deserialize<__D>( __deserializer: __D, ) -> Result<NeoInteger, <__D as Deserializer<'de>>::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl Display for NeoInteger

Source§

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

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

impl Div for NeoInteger

Source§

type Output = NeoInteger

The resulting type after applying the / operator.
Source§

fn div(self, rhs: NeoInteger) -> <NeoInteger as Div>::Output

Performs the / operation. Read more
Source§

impl Div<&NeoInteger> for NeoInteger

Source§

type Output = NeoInteger

The resulting type after applying the / operator.
Source§

fn div(self, rhs: &NeoInteger) -> <NeoInteger as Div<&NeoInteger>>::Output

Performs the / operation. Read more
Source§

impl Div<&NeoInteger> for &NeoInteger

Source§

type Output = NeoInteger

The resulting type after applying the / operator.
Source§

fn div(self, rhs: &NeoInteger) -> <&NeoInteger as Div<&NeoInteger>>::Output

Performs the / operation. Read more
Source§

impl Div<NeoInteger> for &NeoInteger

Source§

type Output = NeoInteger

The resulting type after applying the / operator.
Source§

fn div(self, rhs: NeoInteger) -> <&NeoInteger as Div<NeoInteger>>::Output

Performs the / operation. Read more
Source§

impl Eq for NeoInteger

Source§

impl From<&BigInt> for NeoInteger

Source§

fn from(value: &BigInt) -> NeoInteger

Converts to this type from the input type.
Source§

impl From<BigInt> for NeoInteger

Source§

fn from(value: BigInt) -> NeoInteger

Converts to this type from the input type.
Source§

impl From<NeoInteger> for NeoValue

Source§

fn from(value: NeoInteger) -> NeoValue

Converts to this type from the input type.
Source§

impl From<i8> for NeoInteger

Source§

fn from(value: i8) -> NeoInteger

Converts to this type from the input type.
Source§

impl From<i16> for NeoInteger

Source§

fn from(value: i16) -> NeoInteger

Converts to this type from the input type.
Source§

impl From<i32> for NeoInteger

Source§

fn from(value: i32) -> NeoInteger

Converts to this type from the input type.
Source§

impl From<i64> for NeoInteger

Source§

fn from(value: i64) -> NeoInteger

Converts to this type from the input type.
Source§

impl From<i128> for NeoInteger

Source§

fn from(value: i128) -> NeoInteger

Converts to this type from the input type.
Source§

impl From<u8> for NeoInteger

Source§

fn from(value: u8) -> NeoInteger

Converts to this type from the input type.
Source§

impl From<u16> for NeoInteger

Source§

fn from(value: u16) -> NeoInteger

Converts to this type from the input type.
Source§

impl From<u32> for NeoInteger

Source§

fn from(value: u32) -> NeoInteger

Converts to this type from the input type.
Source§

impl From<u64> for NeoInteger

Source§

fn from(value: u64) -> NeoInteger

Converts to this type from the input type.
Source§

impl From<u128> for NeoInteger

Source§

fn from(value: u128) -> NeoInteger

Converts to this type from the input type.
Source§

impl FromNeoValue for NeoInteger

Source§

fn from_value(value: &NeoValue) -> Result<NeoInteger, NeoError>

Convert a NeoValue into Self. Returns an error if the value’s runtime type doesn’t match Self’s expected type (e.g. trying to extract an Integer from a String).
Source§

impl Mul for NeoInteger

Source§

type Output = NeoInteger

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: NeoInteger) -> <NeoInteger as Mul>::Output

Performs the * operation. Read more
Source§

impl Mul<&NeoInteger> for NeoInteger

Source§

type Output = NeoInteger

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: &NeoInteger) -> <NeoInteger as Mul<&NeoInteger>>::Output

Performs the * operation. Read more
Source§

impl Mul<&NeoInteger> for &NeoInteger

Source§

type Output = NeoInteger

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: &NeoInteger) -> <&NeoInteger as Mul<&NeoInteger>>::Output

Performs the * operation. Read more
Source§

impl Mul<NeoInteger> for &NeoInteger

Source§

type Output = NeoInteger

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: NeoInteger) -> <&NeoInteger as Mul<NeoInteger>>::Output

Performs the * operation. Read more
Source§

impl Not for NeoInteger

Source§

type Output = NeoInteger

The resulting type after applying the ! operator.
Source§

fn not(self) -> <NeoInteger as Not>::Output

Performs the unary ! operation. Read more
Source§

impl Ord for NeoInteger

Source§

fn cmp(&self, other: &NeoInteger) -> Ordering

This method returns an Ordering between self and other. Read more
1.21.0 (const: unstable) · Source§

fn max(self, other: Self) -> Self
where Self: Sized,

Compares and returns the maximum of two values. Read more
1.21.0 (const: unstable) · Source§

fn min(self, other: Self) -> Self
where Self: Sized,

Compares and returns the minimum of two values. Read more
1.50.0 (const: unstable) · Source§

fn clamp(self, min: Self, max: Self) -> Self
where Self: Sized,

Restrict a value to a certain interval. Read more
Source§

impl PartialEq for NeoInteger

Source§

fn eq(&self, other: &NeoInteger) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl PartialOrd for NeoInteger

Source§

fn partial_cmp(&self, other: &NeoInteger) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 (const: unstable) · Source§

fn lt(&self, other: &Rhs) -> bool

Tests less than (for self and other) and is used by the < operator. Read more
1.0.0 (const: unstable) · Source§

fn le(&self, other: &Rhs) -> bool

Tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 (const: unstable) · Source§

fn gt(&self, other: &Rhs) -> bool

Tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 (const: unstable) · Source§

fn ge(&self, other: &Rhs) -> bool

Tests greater than or equal to (for self and other) and is used by the >= operator. Read more
Source§

impl Rem for NeoInteger

Source§

type Output = NeoInteger

The resulting type after applying the % operator.
Source§

fn rem(self, rhs: NeoInteger) -> <NeoInteger as Rem>::Output

Performs the % operation. Read more
Source§

impl Rem<&NeoInteger> for NeoInteger

Source§

type Output = NeoInteger

The resulting type after applying the % operator.
Source§

fn rem(self, rhs: &NeoInteger) -> <NeoInteger as Rem<&NeoInteger>>::Output

Performs the % operation. Read more
Source§

impl Rem<&NeoInteger> for &NeoInteger

Source§

type Output = NeoInteger

The resulting type after applying the % operator.
Source§

fn rem(self, rhs: &NeoInteger) -> <&NeoInteger as Rem<&NeoInteger>>::Output

Performs the % operation. Read more
Source§

impl Rem<NeoInteger> for &NeoInteger

Source§

type Output = NeoInteger

The resulting type after applying the % operator.
Source§

fn rem(self, rhs: NeoInteger) -> <&NeoInteger as Rem<NeoInteger>>::Output

Performs the % operation. Read more
Source§

impl Serialize for NeoInteger

Source§

fn serialize<__S>( &self, __serializer: __S, ) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl Shl<u32> for NeoInteger

Source§

type Output = NeoInteger

The resulting type after applying the << operator.
Source§

fn shl(self, rhs: u32) -> <NeoInteger as Shl<u32>>::Output

Performs the << operation. Read more
Source§

impl Shl<u32> for &NeoInteger

Source§

type Output = NeoInteger

The resulting type after applying the << operator.
Source§

fn shl(self, rhs: u32) -> <&NeoInteger as Shl<u32>>::Output

Performs the << operation. Read more
Source§

impl Shr<u32> for NeoInteger

Source§

type Output = NeoInteger

The resulting type after applying the >> operator.
Source§

fn shr(self, rhs: u32) -> <NeoInteger as Shr<u32>>::Output

Performs the >> operation. Read more
Source§

impl Shr<u32> for &NeoInteger

Source§

type Output = NeoInteger

The resulting type after applying the >> operator.
Source§

fn shr(self, rhs: u32) -> <&NeoInteger as Shr<u32>>::Output

Performs the >> operation. Read more
Source§

impl StructuralPartialEq for NeoInteger

Source§

impl Sub for NeoInteger

Source§

type Output = NeoInteger

The resulting type after applying the - operator.
Source§

fn sub(self, rhs: NeoInteger) -> <NeoInteger as Sub>::Output

Performs the - operation. Read more
Source§

impl Sub<&NeoInteger> for NeoInteger

Source§

type Output = NeoInteger

The resulting type after applying the - operator.
Source§

fn sub(self, rhs: &NeoInteger) -> <NeoInteger as Sub<&NeoInteger>>::Output

Performs the - operation. Read more
Source§

impl Sub<&NeoInteger> for &NeoInteger

Source§

type Output = NeoInteger

The resulting type after applying the - operator.
Source§

fn sub(self, rhs: &NeoInteger) -> <&NeoInteger as Sub<&NeoInteger>>::Output

Performs the - operation. Read more
Source§

impl Sub<NeoInteger> for &NeoInteger

Source§

type Output = NeoInteger

The resulting type after applying the - operator.
Source§

fn sub(self, rhs: NeoInteger) -> <&NeoInteger as Sub<NeoInteger>>::Output

Performs the - operation. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

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

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

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

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

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

Source§

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

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

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

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, Rhs, Output> NumOps<Rhs, Output> for T
where T: Sub<Rhs, Output = Output> + Mul<Rhs, Output = Output> + Div<Rhs, Output = Output> + Add<Rhs, Output = Output> + Rem<Rhs, Output = Output>,

Source§

impl<T, Base> RefNum<Base> for T
where T: NumOps<Base, Base> + for<'r> NumOps<&'r Base, Base>,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

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> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

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

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

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

Performs the conversion.
Source§

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

Source§

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

The type returned in the event of a conversion error.
Source§

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

Performs the conversion.