[−][src]Struct rdp::model::data::DynOption
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]
F: Fn(&T) -> MessageOption,
F: Send,
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
Auto Trait Implementations
impl<T> !RefUnwindSafe for DynOption<T>
impl<T> Send for DynOption<T> where
T: Send,
T: Send,
impl<T> !Sync for DynOption<T>
impl<T> Unpin for DynOption<T> where
T: Unpin,
T: Unpin,
impl<T> !UnwindSafe for DynOption<T>
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
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]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
V: MultiLane<T>,