sheave_core::messages::amf::v0

Struct Object

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

The anonymous object type of AMF. This consists of pairs of string keys and any AMF data types.

  • Key

The string which doesn’t have its marker. This type is named as UnmarkedString in this crate. Also this occurs the panic if its length exceeds the range of 16 bits.

  • Value

The pointer for AMF data types, which is wrapped into Arc. This is because of avoiding to be deallocated its value unexpectedly.

You can access to properties which this constains, as the HashMap.

§Example

use sheave_core::{
    messages::amf::v0::AmfString,
    object
};

let mut object = object!(
    "app" => AmfString::from("ondemand")
);
object.get_properties().get("app");
&object.get_properties()["app"];

Implementations§

Source§

impl Object

Source

pub fn new(properties: Properties) -> Self

Constrcuts a new object.

Source

pub fn get_properties(&self) -> &Properties

Gets immutable properties from this object.

Source

pub fn get_properties_mut(&mut self) -> &mut Properties

Gets mutable properties from this object.

Trait Implementations§

Source§

impl Clone for Object

Source§

fn clone(&self) -> Object

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 Object

Source§

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

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

impl Decoder<Object> for ByteBuffer

Source§

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

Decodes bytes into an AMF’s Object type.

§Errors

When buffer isn’t remained at least 2 bytes. (non-empty object contains at least one pair of key and value)

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

When key bytes are invalid for a UTF-8 string.

§Examples
use sheave_core::{
    ByteBuffer,
    Decoder,
    messages::amf::v0::{
        Marker,
        Object
    }
};

let mut buffer = ByteBuffer::default();
buffer.put_u8(Marker::Object as u8);
// AMF's Object type is required a marker of object end (0x09) which is associated with an empty key.
buffer.put_u16_be(0);
buffer.put_u8(Marker::ObjectEnd as u8);
assert!(Decoder::<Object>::decode(&mut buffer).is_ok());

let mut buffer = ByteBuffer::default();
buffer.put_u8(Marker::Number as u8);
buffer.put_u16_be(0);
buffer.put_u8(Marker::ObjectEnd as u8);
assert!(Decoder::<Object>::decode(&mut buffer).is_err());

// This is a missing sequence of the "sparkle heart(💖)".
let mut bytes = vec![0, 159, 146, 150];
let mut buffer = ByteBuffer::default();
buffer.put_u8(Marker::Object as u8);
buffer.put_u16_be(4);
buffer.put_bytes(&bytes);
buffer.put_u8(Marker::Number as u8);
buffer.put_f64(0.0);
buffer.put_u16_be(0);
buffer.put_u8(Marker::ObjectEnd as u8);
assert!(Decoder::<Object>::decode(&mut buffer).is_err());

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

impl Default for Object

Source§

fn default() -> Object

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

impl Encoder<Object> for ByteBuffer

Source§

fn encode(&mut self, object: &Object)

Encodes an AMF’s Object into bytes.

Source§

impl From<Connect> for Object

Source§

fn from(connect: Connect) -> Self

Converts to this type from the input type.
Source§

impl From<OnStatus> for Object

Source§

fn from(on_status: OnStatus) -> Self

Converts to this type from the input type.
Source§

impl PartialEq for Object

Source§

fn eq(&self, other: &Object) -> 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 Eq for Object

Source§

impl StructuralPartialEq for Object

Auto Trait Implementations§

§

impl Freeze for Object

§

impl RefUnwindSafe for Object

§

impl Send for Object

§

impl Sync for Object

§

impl Unpin for Object

§

impl UnwindSafe for Object

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, 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