Struct EcmaArray

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

The sized object type of AMF. This consists of:

  • Count

The unsigned 32 bits integer.

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.

This is expected its size is same as the above count.

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

§Examples

use sheave_core::{
    ecma_array,
    messages::amf::v0::{
        EcmaArray,
        Number
    },
};

let ecma_array = ecma_array!(
    "videocodecid" => Number::from(0)
);
ecma_array.get_properties().get("videocodecid");
&ecma_array.get_properties()["videocodecid"];

Implementations§

Source§

impl EcmaArray

Source

pub fn new(properties: Properties) -> Self

Constructs a new ECMA array.

Source

pub fn get_properties(&self) -> &Properties

Gets immutable properties from this array.

Source

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

Gets mutable properties from this array.

Trait Implementations§

Source§

impl Clone for EcmaArray

Source§

fn clone(&self) -> EcmaArray

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 EcmaArray

Source§

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

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

impl Decoder<EcmaArray> for ByteBuffer

Source§

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

Decodes bytes into an ECMA array.

§Errors

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

When a marker byte doesn’t indicate the ECMA array.

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

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

let mut buffer = ByteBuffer::default();
buffer.put_u8(Marker::EcmaArray as u8);
buffer.put_u32_be(0);
// Also ECMA array 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::<EcmaArray>::decode(&mut buffer).is_ok());

let mut buffer = ByteBuffer::default();
buffer.put_u8(Marker::Number as u8);
buffer.put_u32_be(0);
buffer.put_u16_be(0);
buffer.put_u8(Marker::ObjectEnd as u8);
assert!(Decoder::<EcmaArray>::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::EcmaArray as u8);
buffer.put_u32_be(0);
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::<EcmaArray>::decode(&mut buffer).is_err());

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

Note the length field will not be so cared because to decodde is enough to check the object end marker (0x09). However warning will emit if lengths is inconsistent.

Source§

impl Default for EcmaArray

Source§

fn default() -> EcmaArray

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

impl Encoder<EcmaArray> for ByteBuffer

Source§

fn encode(&mut self, ecma_array: &EcmaArray)

Encodes an ECMA array into bytes.

§Panics

Its length must be the range of 32 bits. If it exceeds, a panic is occured.

Source§

impl From<SetPlaylist> for EcmaArray

Source§

fn from(set_playlist: SetPlaylist) -> Self

Converts to this type from the input type.
Source§

impl PartialEq for EcmaArray

Source§

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

Source§

impl StructuralPartialEq for EcmaArray

Auto Trait Implementations§

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, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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