sheave_core::messages::amf::v0

Struct Number

Source
pub struct Number(/* private fields */);
Expand description

The IEEE 754 double precision floating point number of AMF data types.

Implementations§

Source§

impl Number

Source

pub fn new(number: f64) -> Self

Constructs an AMF’s Number.

Source

pub fn as_integer(&self) -> u64

Gets an inner value as an integer. This is prepared for converting any message ID to an integer from an AMF’s number.

Trait Implementations§

Source§

impl Add<f64> for Number

Source§

type Output = Number

The resulting type after applying the + operator.
Source§

fn add(self, rhs: f64) -> Self::Output

Performs the + operation. Read more
Source§

impl Add for Number

Source§

type Output = Number

The resulting type after applying the + operator.
Source§

fn add(self, rhs: Self) -> Self::Output

Performs the + operation. Read more
Source§

impl AddAssign<f64> for Number

Source§

fn add_assign(&mut self, rhs: f64)

Performs the += operation. Read more
Source§

impl AddAssign for Number

Source§

fn add_assign(&mut self, rhs: Self)

Performs the += operation. Read more
Source§

impl Clone for Number

Source§

fn clone(&self) -> Number

Returns a copy of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Number

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Decoder<Number> for ByteBuffer

Source§

fn decode(&mut self) -> IOResult<Number>

Decodes bytes into an AMF’s Number.

§Errors

When buffer isn’t remained at least 9 bytes.

When a marker byte doesn’t indicate the AMF Number.

§Examples
use rand::random;
use sheave_core::{
    ByteBuffer,
    Decoder,
    messages::amf::v0::{
        Marker,
        Number
    }
};

let mut buffer = ByteBuffer::default();
buffer.put_u8(Marker::Number as u8);
buffer.put_f64(f64::from_bits(random::<u64>()));
assert!(Decoder::<Number>::decode(&mut buffer).is_ok());

let mut buffer = ByteBuffer::default();
buffer.put_u8(Marker::Boolean as u8);
buffer.put_f64(f64::from_bits(random::<u64>()));
assert!(Decoder::<Number>::decode(&mut buffer).is_err());

let mut buffer = ByteBuffer::default();
assert!(Decoder::<Number>::decode(&mut buffer).is_err())
Source§

impl Default for Number

Source§

fn default() -> Number

Returns the “default value” for a type. Read more
Source§

impl Display for Number

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> FormatResult

Formats the value using the given formatter. Read more
Source§

impl Encoder<Number> for ByteBuffer

Source§

fn encode(&mut self, n: &Number)

Encodes an AMF’s Number into bytes.

Source§

impl From<bool> for Number

Source§

fn from(number: bool) -> Self

Converts to this type from the input type.
Source§

impl From<f32> for Number

Source§

fn from(number: f32) -> Self

Converts to this type from the input type.
Source§

impl From<i16> for Number

Source§

fn from(number: i16) -> Self

Converts to this type from the input type.
Source§

impl From<i32> for Number

Source§

fn from(number: i32) -> Self

Converts to this type from the input type.
Source§

impl From<i8> for Number

Source§

fn from(number: i8) -> Self

Converts to this type from the input type.
Source§

impl From<u16> for Number

Source§

fn from(number: u16) -> Self

Converts to this type from the input type.
Source§

impl From<u32> for Number

Source§

fn from(number: u32) -> Self

Converts to this type from the input type.
Source§

impl From<u8> for Number

Source§

fn from(number: u8) -> Self

Converts to this type from the input type.
Source§

impl PartialEq<Number> for f64

Source§

fn eq(&self, other: &Number) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl PartialEq<f64> for Number

Source§

fn eq(&self, other: &f64) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl PartialEq for Number

Source§

fn eq(&self, other: &Number) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl PartialOrd<Number> for f64

Source§

fn partial_cmp(&self, other: &Number) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 · Source§

fn lt(&self, other: &Rhs) -> bool

Tests less than (for self and other) and is used by the < operator. Read more
1.0.0 · Source§

fn le(&self, other: &Rhs) -> bool

Tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 · Source§

fn gt(&self, other: &Rhs) -> bool

Tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 · Source§

fn ge(&self, other: &Rhs) -> bool

Tests greater than or equal to (for self and other) and is used by the >= operator. Read more
Source§

impl PartialOrd<f64> for Number

Source§

fn partial_cmp(&self, other: &f64) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 · Source§

fn lt(&self, other: &Rhs) -> bool

Tests less than (for self and other) and is used by the < operator. Read more
1.0.0 · Source§

fn le(&self, other: &Rhs) -> bool

Tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 · Source§

fn gt(&self, other: &Rhs) -> bool

Tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 · Source§

fn ge(&self, other: &Rhs) -> bool

Tests greater than or equal to (for self and other) and is used by the >= operator. Read more
Source§

impl PartialOrd for Number

Source§

fn partial_cmp(&self, other: &Number) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 · Source§

fn lt(&self, other: &Rhs) -> bool

Tests less than (for self and other) and is used by the < operator. Read more
1.0.0 · Source§

fn le(&self, other: &Rhs) -> bool

Tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 · Source§

fn gt(&self, other: &Rhs) -> bool

Tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 · Source§

fn ge(&self, other: &Rhs) -> bool

Tests greater than or equal to (for self and other) and is used by the >= operator. Read more
Source§

impl Copy for Number

Source§

impl StructuralPartialEq for Number

Auto Trait Implementations§

§

impl Freeze for Number

§

impl RefUnwindSafe for Number

§

impl Send for Number

§

impl Sync for Number

§

impl Unpin for Number

§

impl UnwindSafe for Number

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dst: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dst. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

default fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

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

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V