pub struct Array<T> { /* private fields */ }
Implementations§
Source§impl<T: Message> Array<T>
impl<T: Message> Array<T>
Sourcepub fn new<F>(factory: F) -> Self
pub fn new<F>(factory: F) -> Self
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);
Sourcepub fn from_trame(inner: Trame) -> Self
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
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
impl<T> AsRef<Vec<Box<dyn Message>>> for Array<T>
Convenient method to get access to the inner type
Source§impl<T: 'static + Message> Message for Array<T>
Implement the message trait for Array
impl<T: 'static + Message> Message for Array<T>
Implement the message trait for Array
Source§fn write(&self, writer: &mut dyn Write) -> RdpResult<()>
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<()>
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
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<'_>
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
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> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more