Struct Array

Source
pub struct Array<T> { /* private fields */ }

Implementations§

Source§

impl<T: Message> Array<T>

Source

pub fn new<F>(factory: F) -> Self
where F: Fn() -> T + Send + 'static,

Create a new dynamic array This kind of array array are filled until the end of the stream, or sub stream if you use DynOption

§Example
#[macro_use]
    let mut s = Cursor::new(vec![0, 0, 1, 0]);
    let mut dyn_array = Array::new(|| U16::LE(0));
    dyn_array.read(&mut s);
    assert_eq!(dyn_array.as_ref().len(), 2);
    assert_eq!(cast!(DataType::U16, dyn_array.as_ref()[0]).unwrap(), 0);
    assert_eq!(cast!(DataType::U16, dyn_array.as_ref()[1]).unwrap(), 1);
Source

pub fn from_trame(inner: Trame) -> Self

This is to be symmetric We can instanciate an array directly from a trame This is for the write side of the pattern

Source

pub fn inner(&self) -> &Trame

Trait Implementations§

Source§

impl<T> AsRef<Vec<Box<dyn Message>>> for Array<T>

Convenient method to get access to the inner type

Source§

fn as_ref(&self) -> &Trame

Converts this type into a shared reference of the (usually inferred) input type.
Source§

impl<T: 'static + Message> Message for Array<T>

Implement the message trait for Array

Source§

fn write(&self, writer: &mut dyn Write) -> RdpResult<()>

Write an array You may not use even if it works prefer using trame object

Source§

fn read(&mut self, reader: &mut dyn Read) -> RdpResult<()>

Read a dynamic array

§Example
use std::io::Cursor;
use rdp::model::data::{U16, Array, Message};
let mut s = Cursor::new(vec![0, 0, 1, 0]);
let mut dyn_array = Array::new(|| U16::LE(0));
dyn_array.read(&mut s);
assert_eq!(dyn_array.as_ref().len(), 2)
Source§

fn length(&self) -> u64

This is the length of the inner trame

§Example
use std::io::Cursor;
use rdp::model::data::{U16, Array, Message};
let mut s = Cursor::new(vec![0, 0, 1, 0]);
let mut dyn_array = Array::new(|| U16::LE(0));
dyn_array.read(&mut s);
assert_eq!(dyn_array.length(), 4)
Source§

fn visit(&self) -> DataType<'_>

Visit the inner trame It’s means always return a slice Prefer using as_ref and visit

Source§

fn options(&self) -> MessageOption

This kind of message have no option

Auto Trait Implementations§

§

impl<T> Freeze for Array<T>

§

impl<T> !RefUnwindSafe for Array<T>

§

impl<T> Send for Array<T>

§

impl<T> !Sync for Array<T>

§

impl<T> Unpin for Array<T>

§

impl<T> !UnwindSafe for Array<T>

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> 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, 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.
Source§

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

Source§

fn vzip(self) -> V