Struct cardano_serialization_lib::utils::Int
source · [−]pub struct Int(_);
Implementations
sourceimpl Int
impl Int
pub fn from_bytes(bytes: Vec<u8>) -> Result<Int, DeserializeError>
sourceimpl Int
impl Int
pub fn new(x: &BigNum) -> Self
pub fn new_negative(x: &BigNum) -> Self
pub fn new_i32(x: i32) -> Self
pub fn is_positive(&self) -> bool
sourcepub fn as_positive(&self) -> Option<BigNum>
pub fn as_positive(&self) -> Option<BigNum>
BigNum can only contain unsigned u64 values
This function will return the BigNum representation only in case the underlying i128 value is positive.
Otherwise nothing will be returned (undefined).
sourcepub fn as_negative(&self) -> Option<BigNum>
pub fn as_negative(&self) -> Option<BigNum>
BigNum can only contain unsigned u64 values
This function will return the absolute BigNum representation only in case the underlying i128 value is negative.
Otherwise nothing will be returned (undefined).
sourcepub fn as_i32(&self) -> Option<i32>
👎 Deprecated since 10.0.0: Unsafe ignoring of possible boundary error and it’s not clear from the function name. Use as_i32_or_nothing
, as_i32_or_fail
, or to_str
pub fn as_i32(&self) -> Option<i32>
Unsafe ignoring of possible boundary error and it’s not clear from the function name. Use as_i32_or_nothing
, as_i32_or_fail
, or to_str
!!! DEPRECATED !!! Returns an i32 value in case the underlying original i128 value is within the limits. Otherwise will just return an empty value (undefined).
sourcepub fn as_i32_or_nothing(&self) -> Option<i32>
pub fn as_i32_or_nothing(&self) -> Option<i32>
Returns the underlying value converted to i32 if possible (within limits) Otherwise will just return an empty value (undefined).
sourcepub fn as_i32_or_fail(&self) -> Result<i32, JsError>
pub fn as_i32_or_fail(&self) -> Result<i32, JsError>
Returns the underlying value converted to i32 if possible (within limits) JsError in case of out of boundary overflow
sourcepub fn to_str(&self) -> String
pub fn to_str(&self) -> String
Returns string representation of the underlying i128 value directly. Might contain the minus sign (-) in case of negative value.
pub fn from_str(string: &str) -> Result<Int, JsError>
Trait Implementations
sourceimpl<'de> Deserialize<'de> for Int
impl<'de> Deserialize<'de> for Int
sourcefn deserialize<D>(deserializer: D) -> Result<Self, D::Error> where
D: Deserializer<'de>,
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error> where
D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
sourceimpl Deserialize for Int
impl Deserialize for Int
fn deserialize<R: BufRead + Seek>(
raw: &mut Deserializer<R>
) -> Result<Self, DeserializeError>
sourceimpl JsonSchema for Int
impl JsonSchema for Int
sourcefn schema_name() -> String
fn schema_name() -> String
The name of the generated JSON Schema. Read more
sourcefn json_schema(gen: &mut SchemaGenerator) -> Schema
fn json_schema(gen: &mut SchemaGenerator) -> Schema
Generates a JSON Schema for this type. Read more
sourcefn is_referenceable() -> bool
fn is_referenceable() -> bool
Whether JSON Schemas generated for this type should be re-used where possible using the $ref
keyword. Read more
sourceimpl Ord for Int
impl Ord for Int
1.21.0 · sourcefn max(self, other: Self) -> Self
fn max(self, other: Self) -> Self
Compares and returns the maximum of two values. Read more
1.21.0 · sourcefn min(self, other: Self) -> Self
fn min(self, other: Self) -> Self
Compares and returns the minimum of two values. Read more
1.50.0 · sourcefn clamp(self, min: Self, max: Self) -> Self where
Self: PartialOrd<Self>,
fn clamp(self, min: Self, max: Self) -> Self where
Self: PartialOrd<Self>,
Restrict a value to a certain interval. Read more
sourceimpl PartialOrd<Int> for Int
impl PartialOrd<Int> for Int
sourcefn partial_cmp(&self, other: &Int) -> Option<Ordering>
fn partial_cmp(&self, other: &Int) -> Option<Ordering>
This method returns an ordering between self
and other
values if one exists. Read more
1.0.0 · sourcefn lt(&self, other: &Rhs) -> bool
fn lt(&self, other: &Rhs) -> bool
This method tests less than (for self
and other
) and is used by the <
operator. Read more
1.0.0 · sourcefn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
This method tests less than or equal to (for self
and other
) and is used by the <=
operator. Read more
sourceimpl Serialize for Int
impl Serialize for Int
fn serialize<'se, W: Write>(
&self,
serializer: &'se mut Serializer<W>
) -> Result<&'se mut Serializer<W>>
impl Eq for Int
impl StructuralEq for Int
impl StructuralPartialEq for Int
Auto Trait Implementations
impl RefUnwindSafe for Int
impl Send for Int
impl Sync for Int
impl Unpin for Int
impl UnwindSafe for Int
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more