[−][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 Plain 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 Default for SafeLong
[src]
impl Copy for SafeLong
[src]
impl Ord for SafeLong
[src]
fn cmp(&self, other: &SafeLong) -> Ordering
[src]
fn max(self, other: Self) -> Self
1.21.0[src]
Compares and returns the maximum of two values. Read more
fn min(self, other: Self) -> Self
1.21.0[src]
Compares and returns the minimum of two values. Read more
fn clamp(self, min: Self, max: Self) -> Self
[src]
clamp
)Restrict a value to a certain interval. Read more
impl Clone for SafeLong
[src]
fn clone(&self) -> 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]
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 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<__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,
Feeds a slice of this type into the given [Hasher
]. Read more
impl Deref for SafeLong
[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 Serialize 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>,
Auto Trait Implementations
Blanket Implementations
impl<T> ToPlain for T where
T: Plain + ?Sized,
[src]
T: Plain + ?Sized,
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> From<T> for T
[src]
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> 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>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> DeserializeOwned for T where
T: Deserialize<'de>,
[src]
T: Deserialize<'de>,