[][src]Struct rdp::model::data::DynOption

pub struct DynOption<T> { /* fields omitted */ }

Methods

impl<T> DynOption<T>[src]

The filter impl A filter work like a proxy pattern for an inner object

pub fn new<F: 'static>(current: T, filter: F) -> Self where
    F: Fn(&T) -> MessageOption,
    F: Send
[src]

Create a new filter from a callback Callback may return a list of field name taht will be skip by the component reader

The following example add a dynamic skip option

Example

#[macro_use]
    let message = component![
        "flag" => DynOption::new(U32::LE(1), |flag| {
            if flag.inner() == 1 {
                return MessageOption::SkipField("depend".to_string());
            }
            else {
                return MessageOption::None;
            }
        }),
        "depend" => U32::LE(0)
    ];
    assert_eq!(message.length(), 4);

The next example use dynamic option to set a size to a value

Example

#[macro_use]
    let mut message = component![
        "Type" => DynOption::new(U32::LE(0), |flag| {
            MessageOption::Size("Value".to_string(), flag.inner() as usize)
        }),
        "Value" => Vec::<u8>::new()
    ];
    let mut stream = Cursor::new(vec![1,0,0,0,1]);
    message.read(&mut stream).unwrap();
    assert_eq!(cast!(DataType::Slice, message["Value"]).unwrap().len(), 1);

Trait Implementations

impl<T: Message> Message for DynOption<T>[src]

Dynamic option is a transparent object for the inner

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

Transparent

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

Transparent

fn length(&self) -> u64[src]

Transparent

fn visit(&self) -> DataType[src]

Transparent

fn options(&self) -> MessageOption[src]

Transparent

Auto Trait Implementations

impl<T> !RefUnwindSafe for DynOption<T>

impl<T> Send for DynOption<T> where
    T: Send

impl<T> !Sync for DynOption<T>

impl<T> Unpin for DynOption<T> where
    T: Unpin

impl<T> !UnwindSafe for DynOption<T>

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> Same<T> for T

type Output = T

Should always be Self

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.

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