[][src]Struct conjure_object::safe_long::SafeLong

pub struct SafeLong(_);

An i64 limited to a range safely representable in JSON.

JSON does not specify requirements of its numeric type, which can lead to issues interoperating between different JSON libraries and languages. In particular, some implementations (including Javascript) interpret numbers as double precision floating point values. Sufficiently large 64-bit integers are not exactly representable as doubles which can cause bugs as numbers change value as they're transmitted from place to place.

The SafeLong type wraps an i64, and avoids these issues by limiting its value to the range that is exactly representable in a double: values between -253 + 1 and 253 - 1.

Methods

impl SafeLong[src]

pub fn min_value() -> SafeLong[src]

Returns the smallest valid SafeLong.

pub fn max_value() -> SafeLong[src]

Returns the largest valid SafeLong.

pub fn new(value: i64) -> Result<SafeLong, BoundsError>[src]

Creates a new SafeLong from an i64.

Returns an error if the value is out of range.

Trait Implementations

impl Plain for SafeLong[src]

impl FromPlain for SafeLong[src]

type Err = <SafeLong as FromStr>::Err

The error type returned when parsing fails.

impl Default for SafeLong[src]

impl Copy for SafeLong[src]

impl Ord for SafeLong[src]

fn max(self, other: Self) -> Self1.21.0[src]

Compares and returns the maximum of two values. Read more

fn min(self, other: Self) -> Self1.21.0[src]

Compares and returns the minimum of two values. Read more

fn clamp(self, min: Self, max: Self) -> Self[src]

🔬 This is a nightly-only experimental API. (clamp)

Restrict a value to a certain interval. Read more

impl Clone for SafeLong[src]

fn clone_from(&mut self, source: &Self)1.0.0[src]

Performs copy-assignment from source. Read more

impl PartialEq<SafeLong> for SafeLong[src]

impl PartialOrd<SafeLong> for SafeLong[src]

impl From<u8> for SafeLong[src]

impl From<i8> for SafeLong[src]

impl From<u16> for SafeLong[src]

impl From<i16> for SafeLong[src]

impl From<u32> for SafeLong[src]

impl From<i32> for SafeLong[src]

impl From<SafeLong> for i64[src]

impl From<SafeLong> for i128[src]

impl Eq for SafeLong[src]

impl Debug for SafeLong[src]

impl Display for SafeLong[src]

impl Hash for SafeLong[src]

fn hash_slice<H>(data: &[Self], state: &mut H) where
    H: Hasher
1.3.0[src]

Feeds a slice of this type into the given [Hasher]. Read more

impl Deref for SafeLong[src]

type Target = i64

The resulting type after dereferencing.

impl FromStr for SafeLong[src]

type Err = ParseError

The associated error which can be returned from parsing.

impl Serialize for SafeLong[src]

impl<'de> Deserialize<'de> for SafeLong[src]

Auto Trait Implementations

impl Send for SafeLong

impl Sync for SafeLong

Blanket Implementations

impl<T> ToPlain for T where
    T: Plain + ?Sized
[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> From<T> for T[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T> ToString for T where
    T: Display + ?Sized
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> Any for T where
    T: 'static + ?Sized
[src]

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