pub struct NeoInteger(/* private fields */);Expand description
Neo N3 Integer type (arbitrary precision)
Implementations§
Source§impl NeoInteger
impl NeoInteger
Sourcepub const MAX_BYTE_LENGTH: usize = 32
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.
pub fn new<T>(value: T) -> NeoInteger
pub fn zero() -> NeoInteger
pub fn one() -> NeoInteger
Sourcepub fn fits_in_neovm(&self) -> bool
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.
Sourcepub fn try_div(&self, rhs: &NeoInteger) -> Result<NeoInteger, NeoError>
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).
Sourcepub fn try_rem(&self, rhs: &NeoInteger) -> Result<NeoInteger, NeoError>
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.
pub fn min_i32() -> NeoInteger
pub fn max_i32() -> NeoInteger
pub fn as_bigint(&self) -> &BigInt
Sourcepub fn to_bigint(&self) -> BigInt
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).
Sourcepub fn from_bigint(value: &BigInt) -> NeoInteger
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.
Sourcepub fn try_as_i32(&self) -> Option<i32>
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.
Sourcepub fn try_as_u32(&self) -> Option<u32>
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.
Sourcepub fn try_as_i64(&self) -> Option<i64>
pub fn try_as_i64(&self) -> Option<i64>
Convert to i64, returning None if the value is out of range.
Sourcepub fn try_as_u64(&self) -> Option<u64>
pub fn try_as_u64(&self) -> Option<u64>
Convert to u64, returning None if the value is out of range.
Sourcepub fn try_into_i32(&self) -> Result<i32, NeoError>
pub fn try_into_i32(&self) -> Result<i32, NeoError>
Convert to i32, returning Result for ergonomic ? usage.
Sourcepub fn try_into_u32(&self) -> Result<u32, NeoError>
pub fn try_into_u32(&self) -> Result<u32, NeoError>
Convert to u32, returning Result for ergonomic ? usage.
Sourcepub fn try_into_i64(&self) -> Result<i64, NeoError>
pub fn try_into_i64(&self) -> Result<i64, NeoError>
Convert to i64, returning Result for ergonomic ? usage.
Sourcepub fn try_into_u64(&self) -> Result<u64, NeoError>
pub fn try_into_u64(&self) -> Result<u64, NeoError>
Convert to u64, returning Result for ergonomic ? usage.
Sourcepub fn as_i32_saturating(&self) -> i32
pub fn as_i32_saturating(&self) -> i32
Convert to i32, saturating at the boundaries if the value is out of range. This never panics.
Sourcepub fn as_u32_saturating(&self) -> u32
pub fn as_u32_saturating(&self) -> u32
Convert to u32, saturating at the boundaries if the value is out of range. This never panics.
Sourcepub fn as_i64_saturating(&self) -> i64
pub fn as_i64_saturating(&self) -> i64
Convert to i64, saturating at the boundaries if the value is out of range. This never panics.
Sourcepub fn as_i32(&self) -> i32
👎Deprecated since 0.1.0: Use try_as_i32() or as_i32_saturating() explicitly
pub fn as_i32(&self) -> i32
Use try_as_i32() or as_i32_saturating() explicitly
Deprecated compatibility helper that converts to i32 using saturating semantics.
Sourcepub fn as_u32(&self) -> u32
👎Deprecated since 0.1.0: Use try_as_u32() or as_u32_saturating() explicitly
pub fn as_u32(&self) -> u32
Use try_as_u32() or as_u32_saturating() explicitly
Deprecated compatibility helper that converts to u32 using saturating semantics.
Sourcepub fn to_i32(&self) -> Option<i32>
👎Deprecated since 0.1.0: Use try_as_i32() instead
pub fn to_i32(&self) -> Option<i32>
Use try_as_i32() instead
Deprecated: use try_as_i32() instead.
Trait Implementations§
Source§impl Add for NeoInteger
impl Add for NeoInteger
Source§type Output = NeoInteger
type Output = NeoInteger
+ operator.Source§fn add(self, rhs: NeoInteger) -> <NeoInteger as Add>::Output
fn add(self, rhs: NeoInteger) -> <NeoInteger as Add>::Output
+ operation. Read moreSource§impl Add<&NeoInteger> for NeoInteger
impl Add<&NeoInteger> for NeoInteger
Source§type Output = NeoInteger
type Output = NeoInteger
+ operator.Source§fn add(self, rhs: &NeoInteger) -> <NeoInteger as Add<&NeoInteger>>::Output
fn add(self, rhs: &NeoInteger) -> <NeoInteger as Add<&NeoInteger>>::Output
+ operation. Read moreSource§impl Add<&NeoInteger> for &NeoInteger
impl Add<&NeoInteger> for &NeoInteger
Source§type Output = NeoInteger
type Output = NeoInteger
+ operator.Source§fn add(self, rhs: &NeoInteger) -> <&NeoInteger as Add<&NeoInteger>>::Output
fn add(self, rhs: &NeoInteger) -> <&NeoInteger as Add<&NeoInteger>>::Output
+ operation. Read moreSource§impl Add<NeoInteger> for &NeoInteger
impl Add<NeoInteger> for &NeoInteger
Source§type Output = NeoInteger
type Output = NeoInteger
+ operator.Source§fn add(self, rhs: NeoInteger) -> <&NeoInteger as Add<NeoInteger>>::Output
fn add(self, rhs: NeoInteger) -> <&NeoInteger as Add<NeoInteger>>::Output
+ operation. Read moreSource§impl BitAnd for NeoInteger
impl BitAnd for NeoInteger
Source§type Output = NeoInteger
type Output = NeoInteger
& operator.Source§fn bitand(self, rhs: NeoInteger) -> <NeoInteger as BitAnd>::Output
fn bitand(self, rhs: NeoInteger) -> <NeoInteger as BitAnd>::Output
& operation. Read moreSource§impl BitAnd<&NeoInteger> for NeoInteger
impl BitAnd<&NeoInteger> for NeoInteger
Source§type Output = NeoInteger
type Output = NeoInteger
& operator.Source§fn bitand(self, rhs: &NeoInteger) -> <NeoInteger as BitAnd<&NeoInteger>>::Output
fn bitand(self, rhs: &NeoInteger) -> <NeoInteger as BitAnd<&NeoInteger>>::Output
& operation. Read moreSource§impl BitAnd<&NeoInteger> for &NeoInteger
impl BitAnd<&NeoInteger> for &NeoInteger
Source§type Output = NeoInteger
type Output = NeoInteger
& operator.Source§fn bitand(
self,
rhs: &NeoInteger,
) -> <&NeoInteger as BitAnd<&NeoInteger>>::Output
fn bitand( self, rhs: &NeoInteger, ) -> <&NeoInteger as BitAnd<&NeoInteger>>::Output
& operation. Read moreSource§impl BitAnd<NeoInteger> for &NeoInteger
impl BitAnd<NeoInteger> for &NeoInteger
Source§type Output = NeoInteger
type Output = NeoInteger
& operator.Source§fn bitand(self, rhs: NeoInteger) -> <&NeoInteger as BitAnd<NeoInteger>>::Output
fn bitand(self, rhs: NeoInteger) -> <&NeoInteger as BitAnd<NeoInteger>>::Output
& operation. Read moreSource§impl BitOr for NeoInteger
impl BitOr for NeoInteger
Source§type Output = NeoInteger
type Output = NeoInteger
| operator.Source§fn bitor(self, rhs: NeoInteger) -> <NeoInteger as BitOr>::Output
fn bitor(self, rhs: NeoInteger) -> <NeoInteger as BitOr>::Output
| operation. Read moreSource§impl BitOr<&NeoInteger> for NeoInteger
impl BitOr<&NeoInteger> for NeoInteger
Source§type Output = NeoInteger
type Output = NeoInteger
| operator.Source§fn bitor(self, rhs: &NeoInteger) -> <NeoInteger as BitOr<&NeoInteger>>::Output
fn bitor(self, rhs: &NeoInteger) -> <NeoInteger as BitOr<&NeoInteger>>::Output
| operation. Read moreSource§impl BitOr<&NeoInteger> for &NeoInteger
impl BitOr<&NeoInteger> for &NeoInteger
Source§type Output = NeoInteger
type Output = NeoInteger
| operator.Source§fn bitor(self, rhs: &NeoInteger) -> <&NeoInteger as BitOr<&NeoInteger>>::Output
fn bitor(self, rhs: &NeoInteger) -> <&NeoInteger as BitOr<&NeoInteger>>::Output
| operation. Read moreSource§impl BitOr<NeoInteger> for &NeoInteger
impl BitOr<NeoInteger> for &NeoInteger
Source§type Output = NeoInteger
type Output = NeoInteger
| operator.Source§fn bitor(self, rhs: NeoInteger) -> <&NeoInteger as BitOr<NeoInteger>>::Output
fn bitor(self, rhs: NeoInteger) -> <&NeoInteger as BitOr<NeoInteger>>::Output
| operation. Read moreSource§impl BitXor for NeoInteger
impl BitXor for NeoInteger
Source§type Output = NeoInteger
type Output = NeoInteger
^ operator.Source§fn bitxor(self, rhs: NeoInteger) -> <NeoInteger as BitXor>::Output
fn bitxor(self, rhs: NeoInteger) -> <NeoInteger as BitXor>::Output
^ operation. Read moreSource§impl BitXor<&NeoInteger> for NeoInteger
impl BitXor<&NeoInteger> for NeoInteger
Source§type Output = NeoInteger
type Output = NeoInteger
^ operator.Source§fn bitxor(self, rhs: &NeoInteger) -> <NeoInteger as BitXor<&NeoInteger>>::Output
fn bitxor(self, rhs: &NeoInteger) -> <NeoInteger as BitXor<&NeoInteger>>::Output
^ operation. Read moreSource§impl BitXor<&NeoInteger> for &NeoInteger
impl BitXor<&NeoInteger> for &NeoInteger
Source§type Output = NeoInteger
type Output = NeoInteger
^ operator.Source§fn bitxor(
self,
rhs: &NeoInteger,
) -> <&NeoInteger as BitXor<&NeoInteger>>::Output
fn bitxor( self, rhs: &NeoInteger, ) -> <&NeoInteger as BitXor<&NeoInteger>>::Output
^ operation. Read moreSource§impl BitXor<NeoInteger> for &NeoInteger
impl BitXor<NeoInteger> for &NeoInteger
Source§type Output = NeoInteger
type Output = NeoInteger
^ operator.Source§fn bitxor(self, rhs: NeoInteger) -> <&NeoInteger as BitXor<NeoInteger>>::Output
fn bitxor(self, rhs: NeoInteger) -> <&NeoInteger as BitXor<NeoInteger>>::Output
^ operation. Read moreSource§impl Clone for NeoInteger
impl Clone for NeoInteger
Source§fn clone(&self) -> NeoInteger
fn clone(&self) -> NeoInteger
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for NeoInteger
impl Debug for NeoInteger
Source§impl Default for NeoInteger
impl Default for NeoInteger
Source§fn default() -> NeoInteger
fn default() -> NeoInteger
Source§impl<'de> Deserialize<'de> for NeoInteger
impl<'de> Deserialize<'de> for NeoInteger
Source§fn deserialize<__D>(
__deserializer: __D,
) -> Result<NeoInteger, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(
__deserializer: __D,
) -> Result<NeoInteger, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
Source§impl Display for NeoInteger
impl Display for NeoInteger
Source§impl Div for NeoInteger
impl Div for NeoInteger
Source§type Output = NeoInteger
type Output = NeoInteger
/ operator.Source§fn div(self, rhs: NeoInteger) -> <NeoInteger as Div>::Output
fn div(self, rhs: NeoInteger) -> <NeoInteger as Div>::Output
/ operation. Read moreSource§impl Div<&NeoInteger> for NeoInteger
impl Div<&NeoInteger> for NeoInteger
Source§type Output = NeoInteger
type Output = NeoInteger
/ operator.Source§fn div(self, rhs: &NeoInteger) -> <NeoInteger as Div<&NeoInteger>>::Output
fn div(self, rhs: &NeoInteger) -> <NeoInteger as Div<&NeoInteger>>::Output
/ operation. Read moreSource§impl Div<&NeoInteger> for &NeoInteger
impl Div<&NeoInteger> for &NeoInteger
Source§type Output = NeoInteger
type Output = NeoInteger
/ operator.Source§fn div(self, rhs: &NeoInteger) -> <&NeoInteger as Div<&NeoInteger>>::Output
fn div(self, rhs: &NeoInteger) -> <&NeoInteger as Div<&NeoInteger>>::Output
/ operation. Read moreSource§impl Div<NeoInteger> for &NeoInteger
impl Div<NeoInteger> for &NeoInteger
Source§type Output = NeoInteger
type Output = NeoInteger
/ operator.Source§fn div(self, rhs: NeoInteger) -> <&NeoInteger as Div<NeoInteger>>::Output
fn div(self, rhs: NeoInteger) -> <&NeoInteger as Div<NeoInteger>>::Output
/ operation. Read moreimpl Eq for NeoInteger
Source§impl From<&BigInt> for NeoInteger
impl From<&BigInt> for NeoInteger
Source§fn from(value: &BigInt) -> NeoInteger
fn from(value: &BigInt) -> NeoInteger
Source§impl From<BigInt> for NeoInteger
impl From<BigInt> for NeoInteger
Source§fn from(value: BigInt) -> NeoInteger
fn from(value: BigInt) -> NeoInteger
Source§impl From<NeoInteger> for NeoValue
impl From<NeoInteger> for NeoValue
Source§fn from(value: NeoInteger) -> NeoValue
fn from(value: NeoInteger) -> NeoValue
Source§impl From<i8> for NeoInteger
impl From<i8> for NeoInteger
Source§fn from(value: i8) -> NeoInteger
fn from(value: i8) -> NeoInteger
Source§impl From<i16> for NeoInteger
impl From<i16> for NeoInteger
Source§fn from(value: i16) -> NeoInteger
fn from(value: i16) -> NeoInteger
Source§impl From<i32> for NeoInteger
impl From<i32> for NeoInteger
Source§fn from(value: i32) -> NeoInteger
fn from(value: i32) -> NeoInteger
Source§impl From<i64> for NeoInteger
impl From<i64> for NeoInteger
Source§fn from(value: i64) -> NeoInteger
fn from(value: i64) -> NeoInteger
Source§impl From<i128> for NeoInteger
impl From<i128> for NeoInteger
Source§fn from(value: i128) -> NeoInteger
fn from(value: i128) -> NeoInteger
Source§impl From<u8> for NeoInteger
impl From<u8> for NeoInteger
Source§fn from(value: u8) -> NeoInteger
fn from(value: u8) -> NeoInteger
Source§impl From<u16> for NeoInteger
impl From<u16> for NeoInteger
Source§fn from(value: u16) -> NeoInteger
fn from(value: u16) -> NeoInteger
Source§impl From<u32> for NeoInteger
impl From<u32> for NeoInteger
Source§fn from(value: u32) -> NeoInteger
fn from(value: u32) -> NeoInteger
Source§impl From<u64> for NeoInteger
impl From<u64> for NeoInteger
Source§fn from(value: u64) -> NeoInteger
fn from(value: u64) -> NeoInteger
Source§impl From<u128> for NeoInteger
impl From<u128> for NeoInteger
Source§fn from(value: u128) -> NeoInteger
fn from(value: u128) -> NeoInteger
Source§impl FromNeoValue for NeoInteger
impl FromNeoValue for NeoInteger
Source§fn from_value(value: &NeoValue) -> Result<NeoInteger, NeoError>
fn from_value(value: &NeoValue) -> Result<NeoInteger, NeoError>
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
impl Mul for NeoInteger
Source§type Output = NeoInteger
type Output = NeoInteger
* operator.Source§fn mul(self, rhs: NeoInteger) -> <NeoInteger as Mul>::Output
fn mul(self, rhs: NeoInteger) -> <NeoInteger as Mul>::Output
* operation. Read moreSource§impl Mul<&NeoInteger> for NeoInteger
impl Mul<&NeoInteger> for NeoInteger
Source§type Output = NeoInteger
type Output = NeoInteger
* operator.Source§fn mul(self, rhs: &NeoInteger) -> <NeoInteger as Mul<&NeoInteger>>::Output
fn mul(self, rhs: &NeoInteger) -> <NeoInteger as Mul<&NeoInteger>>::Output
* operation. Read moreSource§impl Mul<&NeoInteger> for &NeoInteger
impl Mul<&NeoInteger> for &NeoInteger
Source§type Output = NeoInteger
type Output = NeoInteger
* operator.Source§fn mul(self, rhs: &NeoInteger) -> <&NeoInteger as Mul<&NeoInteger>>::Output
fn mul(self, rhs: &NeoInteger) -> <&NeoInteger as Mul<&NeoInteger>>::Output
* operation. Read moreSource§impl Mul<NeoInteger> for &NeoInteger
impl Mul<NeoInteger> for &NeoInteger
Source§type Output = NeoInteger
type Output = NeoInteger
* operator.Source§fn mul(self, rhs: NeoInteger) -> <&NeoInteger as Mul<NeoInteger>>::Output
fn mul(self, rhs: NeoInteger) -> <&NeoInteger as Mul<NeoInteger>>::Output
* operation. Read moreSource§impl Not for NeoInteger
impl Not for NeoInteger
Source§impl Ord for NeoInteger
impl Ord for NeoInteger
Source§fn cmp(&self, other: &NeoInteger) -> Ordering
fn cmp(&self, other: &NeoInteger) -> Ordering
1.21.0 (const: unstable) · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
Source§impl PartialEq for NeoInteger
impl PartialEq for NeoInteger
Source§fn eq(&self, other: &NeoInteger) -> bool
fn eq(&self, other: &NeoInteger) -> bool
self and other values to be equal, and is used by ==.Source§impl PartialOrd for NeoInteger
impl PartialOrd for NeoInteger
Source§impl Rem for NeoInteger
impl Rem for NeoInteger
Source§type Output = NeoInteger
type Output = NeoInteger
% operator.Source§fn rem(self, rhs: NeoInteger) -> <NeoInteger as Rem>::Output
fn rem(self, rhs: NeoInteger) -> <NeoInteger as Rem>::Output
% operation. Read moreSource§impl Rem<&NeoInteger> for NeoInteger
impl Rem<&NeoInteger> for NeoInteger
Source§type Output = NeoInteger
type Output = NeoInteger
% operator.Source§fn rem(self, rhs: &NeoInteger) -> <NeoInteger as Rem<&NeoInteger>>::Output
fn rem(self, rhs: &NeoInteger) -> <NeoInteger as Rem<&NeoInteger>>::Output
% operation. Read moreSource§impl Rem<&NeoInteger> for &NeoInteger
impl Rem<&NeoInteger> for &NeoInteger
Source§type Output = NeoInteger
type Output = NeoInteger
% operator.Source§fn rem(self, rhs: &NeoInteger) -> <&NeoInteger as Rem<&NeoInteger>>::Output
fn rem(self, rhs: &NeoInteger) -> <&NeoInteger as Rem<&NeoInteger>>::Output
% operation. Read moreSource§impl Rem<NeoInteger> for &NeoInteger
impl Rem<NeoInteger> for &NeoInteger
Source§type Output = NeoInteger
type Output = NeoInteger
% operator.Source§fn rem(self, rhs: NeoInteger) -> <&NeoInteger as Rem<NeoInteger>>::Output
fn rem(self, rhs: NeoInteger) -> <&NeoInteger as Rem<NeoInteger>>::Output
% operation. Read moreSource§impl Serialize for NeoInteger
impl Serialize for NeoInteger
Source§fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
Source§impl Shl<u32> for NeoInteger
impl Shl<u32> for NeoInteger
Source§impl Shl<u32> for &NeoInteger
impl Shl<u32> for &NeoInteger
Source§impl Shr<u32> for NeoInteger
impl Shr<u32> for NeoInteger
Source§impl Shr<u32> for &NeoInteger
impl Shr<u32> for &NeoInteger
impl StructuralPartialEq for NeoInteger
Source§impl Sub for NeoInteger
impl Sub for NeoInteger
Source§type Output = NeoInteger
type Output = NeoInteger
- operator.Source§fn sub(self, rhs: NeoInteger) -> <NeoInteger as Sub>::Output
fn sub(self, rhs: NeoInteger) -> <NeoInteger as Sub>::Output
- operation. Read moreSource§impl Sub<&NeoInteger> for NeoInteger
impl Sub<&NeoInteger> for NeoInteger
Source§type Output = NeoInteger
type Output = NeoInteger
- operator.Source§fn sub(self, rhs: &NeoInteger) -> <NeoInteger as Sub<&NeoInteger>>::Output
fn sub(self, rhs: &NeoInteger) -> <NeoInteger as Sub<&NeoInteger>>::Output
- operation. Read moreSource§impl Sub<&NeoInteger> for &NeoInteger
impl Sub<&NeoInteger> for &NeoInteger
Source§type Output = NeoInteger
type Output = NeoInteger
- operator.Source§fn sub(self, rhs: &NeoInteger) -> <&NeoInteger as Sub<&NeoInteger>>::Output
fn sub(self, rhs: &NeoInteger) -> <&NeoInteger as Sub<&NeoInteger>>::Output
- operation. Read moreSource§impl Sub<NeoInteger> for &NeoInteger
impl Sub<NeoInteger> for &NeoInteger
Source§type Output = NeoInteger
type Output = NeoInteger
- operator.Source§fn sub(self, rhs: NeoInteger) -> <&NeoInteger as Sub<NeoInteger>>::Output
fn sub(self, rhs: NeoInteger) -> <&NeoInteger as Sub<NeoInteger>>::Output
- operation. Read more