[−][src]Struct conjure_object::safe_long::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 Clone for SafeLong
[src]
impl Copy for SafeLong
[src]
impl Debug for SafeLong
[src]
impl Default for SafeLong
[src]
impl Deref for SafeLong
[src]
impl<'de> Deserialize<'de> for SafeLong
[src]
fn deserialize<D>(d: D) -> Result<SafeLong, D::Error> where
D: Deserializer<'de>,
[src]
D: Deserializer<'de>,
impl Display for SafeLong
[src]
impl Eq for SafeLong
[src]
impl From<SafeLong> for i64
[src]
impl From<SafeLong> for i128
[src]
impl From<i16> for SafeLong
[src]
impl From<i32> for SafeLong
[src]
impl From<i8> for SafeLong
[src]
impl From<u16> for SafeLong
[src]
impl From<u32> for SafeLong
[src]
impl From<u8> for SafeLong
[src]
impl FromPlain for SafeLong
[src]
type Err = <SafeLong as FromStr>::Err
The error type returned when parsing fails.
fn from_plain(s: &str) -> Result<Self, Self::Err>
[src]
impl FromStr for SafeLong
[src]
type Err = ParseError
The associated error which can be returned from parsing.
fn from_str(s: &str) -> Result<SafeLong, ParseError>
[src]
impl Hash for SafeLong
[src]
fn hash<__H: Hasher>(&self, state: &mut __H)
[src]
fn hash_slice<H>(data: &[Self], state: &mut H) where
H: Hasher,
1.3.0[src]
H: Hasher,
impl Ord for SafeLong
[src]
fn cmp(&self, other: &SafeLong) -> Ordering
[src]
#[must_use]
fn max(self, other: Self) -> Self
1.21.0[src]
#[must_use]
fn min(self, other: Self) -> Self
1.21.0[src]
#[must_use]
fn clamp(self, min: Self, max: Self) -> Self
[src]
impl PartialEq<SafeLong> for SafeLong
[src]
impl PartialOrd<SafeLong> for SafeLong
[src]
fn partial_cmp(&self, other: &SafeLong) -> Option<Ordering>
[src]
fn lt(&self, other: &SafeLong) -> bool
[src]
fn le(&self, other: &SafeLong) -> bool
[src]
fn gt(&self, other: &SafeLong) -> bool
[src]
fn ge(&self, other: &SafeLong) -> bool
[src]
impl Plain for SafeLong
[src]
impl Serialize for SafeLong
[src]
impl StructuralEq for SafeLong
[src]
impl StructuralPartialEq for SafeLong
[src]
impl TryFrom<SafeLong> for u8
[src]
type Error = TryFromIntError
The type returned in the event of a conversion error.
fn try_from(n: SafeLong) -> Result<u8, TryFromIntError>
[src]
impl TryFrom<SafeLong> for i8
[src]
type Error = TryFromIntError
The type returned in the event of a conversion error.
fn try_from(n: SafeLong) -> Result<i8, TryFromIntError>
[src]
impl TryFrom<SafeLong> for u16
[src]
type Error = TryFromIntError
The type returned in the event of a conversion error.
fn try_from(n: SafeLong) -> Result<u16, TryFromIntError>
[src]
impl TryFrom<SafeLong> for i16
[src]
type Error = TryFromIntError
The type returned in the event of a conversion error.
fn try_from(n: SafeLong) -> Result<i16, TryFromIntError>
[src]
impl TryFrom<SafeLong> for u32
[src]
type Error = TryFromIntError
The type returned in the event of a conversion error.
fn try_from(n: SafeLong) -> Result<u32, TryFromIntError>
[src]
impl TryFrom<SafeLong> for i32
[src]
type Error = TryFromIntError
The type returned in the event of a conversion error.
fn try_from(n: SafeLong) -> Result<i32, TryFromIntError>
[src]
impl TryFrom<SafeLong> for u64
[src]
type Error = TryFromIntError
The type returned in the event of a conversion error.
fn try_from(n: SafeLong) -> Result<u64, TryFromIntError>
[src]
impl TryFrom<SafeLong> for u128
[src]
type Error = TryFromIntError
The type returned in the event of a conversion error.
fn try_from(n: SafeLong) -> Result<u128, TryFromIntError>
[src]
impl TryFrom<SafeLong> for usize
[src]
type Error = TryFromIntError
The type returned in the event of a conversion error.
fn try_from(n: SafeLong) -> Result<usize, TryFromIntError>
[src]
impl TryFrom<SafeLong> for isize
[src]
type Error = TryFromIntError
The type returned in the event of a conversion error.
fn try_from(n: SafeLong) -> Result<isize, TryFromIntError>
[src]
impl TryFrom<i128> for SafeLong
[src]
type Error = BoundsError
The type returned in the event of a conversion error.
fn try_from(n: i128) -> Result<SafeLong, BoundsError>
[src]
impl TryFrom<i64> for SafeLong
[src]
type Error = BoundsError
The type returned in the event of a conversion error.
fn try_from(n: i64) -> Result<SafeLong, BoundsError>
[src]
impl TryFrom<isize> for SafeLong
[src]
type Error = BoundsError
The type returned in the event of a conversion error.
fn try_from(n: isize) -> Result<SafeLong, BoundsError>
[src]
impl TryFrom<u128> for SafeLong
[src]
type Error = BoundsError
The type returned in the event of a conversion error.
fn try_from(n: u128) -> Result<SafeLong, BoundsError>
[src]
impl TryFrom<u64> for SafeLong
[src]
type Error = BoundsError
The type returned in the event of a conversion error.
fn try_from(n: u64) -> Result<SafeLong, BoundsError>
[src]
impl TryFrom<usize> for SafeLong
[src]
type Error = BoundsError
The type returned in the event of a conversion error.
fn try_from(n: usize) -> Result<SafeLong, BoundsError>
[src]
Auto Trait Implementations
impl RefUnwindSafe for SafeLong
impl Send for SafeLong
impl Sync for SafeLong
impl Unpin for SafeLong
impl UnwindSafe for SafeLong
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> DeserializeOwned for T where
T: Deserialize<'de>,
[src]
T: Deserialize<'de>,
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
fn to_owned(&self) -> T
[src]
fn clone_into(&self, target: &mut T)
[src]
impl<T> ToPlain for T where
T: Plain + ?Sized,
[src]
T: Plain + ?Sized,
impl<T> ToString for T where
T: Display + ?Sized,
[src]
T: Display + ?Sized,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,