[][src]Struct conjure_object::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 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 Clone for SafeLong[src]

impl Copy for SafeLong[src]

impl Default for SafeLong[src]

impl Eq for SafeLong[src]

impl Ord for SafeLong[src]

impl PartialEq<SafeLong> for SafeLong[src]

impl PartialOrd<SafeLong> for SafeLong[src]

impl Display for SafeLong[src]

impl Debug for SafeLong[src]

impl TryFrom<u64> for SafeLong[src]

type Error = BoundsError

The type returned in the event of a conversion error.

impl TryFrom<i64> for SafeLong[src]

type Error = BoundsError

The type returned in the event of a conversion error.

impl TryFrom<u128> for SafeLong[src]

type Error = BoundsError

The type returned in the event of a conversion error.

impl TryFrom<i128> for SafeLong[src]

type Error = BoundsError

The type returned in the event of a conversion error.

impl TryFrom<usize> for SafeLong[src]

type Error = BoundsError

The type returned in the event of a conversion error.

impl TryFrom<isize> for SafeLong[src]

type Error = BoundsError

The type returned in the event of a conversion error.

impl TryFrom<SafeLong> for u8[src]

type Error = TryFromIntError

The type returned in the event of a conversion error.

impl TryFrom<SafeLong> for i8[src]

type Error = TryFromIntError

The type returned in the event of a conversion error.

impl TryFrom<SafeLong> for u16[src]

type Error = TryFromIntError

The type returned in the event of a conversion error.

impl TryFrom<SafeLong> for i16[src]

type Error = TryFromIntError

The type returned in the event of a conversion error.

impl TryFrom<SafeLong> for u32[src]

type Error = TryFromIntError

The type returned in the event of a conversion error.

impl TryFrom<SafeLong> for i32[src]

type Error = TryFromIntError

The type returned in the event of a conversion error.

impl TryFrom<SafeLong> for u64[src]

type Error = TryFromIntError

The type returned in the event of a conversion error.

impl TryFrom<SafeLong> for u128[src]

type Error = TryFromIntError

The type returned in the event of a conversion error.

impl TryFrom<SafeLong> for usize[src]

type Error = TryFromIntError

The type returned in the event of a conversion error.

impl TryFrom<SafeLong> for isize[src]

type Error = TryFromIntError

The type returned in the event of a conversion error.

impl FromStr for SafeLong[src]

type Err = ParseError

The associated error which can be returned from parsing.

impl Deref for SafeLong[src]

type Target = i64

The resulting type after dereferencing.

impl Hash for SafeLong[src]

impl StructuralPartialEq for SafeLong[src]

impl StructuralEq for SafeLong[src]

impl Serialize for SafeLong[src]

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

Auto Trait Implementations

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> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<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]