Enum Stream

Source
pub enum Stream<S> {
    Raw(S),
    Ssl(TlsStream<S>),
}
Expand description

This a wrapper to work equals for a stream and a TLS stream

Variants§

§

Raw(S)

Raw stream that implement Read + Write

§

Ssl(TlsStream<S>)

TLS Stream

Implementations§

Source§

impl<S: Read + Write> Stream<S>

Source

pub fn read_exact(&mut self, buf: &mut [u8]) -> RdpResult<()>

Read exactly the number of bytes present in buffer

§Example
use rdp::model::link::Stream;
use std::io::Cursor;
let mut s = Stream::Raw(Cursor::new(vec![1, 2, 3]));
let mut result = [0, 0];
s.read_exact(&mut result).unwrap();
assert_eq!(result, [1, 2])
Source

pub fn read(&mut self, buf: &mut [u8]) -> RdpResult<usize>

Read all available buffer

§Example
use rdp::model::link::Stream;
use std::io::Cursor;
let mut s = Stream::Raw(Cursor::new(vec![1, 2, 3]));
let mut result = [0, 0, 0, 0];
s.read(&mut result).unwrap();
assert_eq!(result, [1, 2, 3, 0])
Source

pub fn write(&mut self, buffer: &[u8]) -> RdpResult<usize>

Write all buffer to the stream

§Example
use rdp::model::link::Stream;
use std::io::Cursor;
let mut s = Stream::Raw(Cursor::new(vec![]));
let result = [1, 2, 3, 4];
s.write(&result).unwrap();
if let Stream::Raw(r) = s {
    assert_eq!(r.into_inner(), [1, 2, 3, 4])
}
else {
    panic!("invalid")
}
Source

pub fn shutdown(&mut self) -> RdpResult<()>

Shutdown the stream Only works when stream is a SSL stream

Auto Trait Implementations§

§

impl<S> Freeze for Stream<S>
where S: Freeze,

§

impl<S> RefUnwindSafe for Stream<S>
where S: RefUnwindSafe,

§

impl<S> Send for Stream<S>
where S: Send,

§

impl<S> Sync for Stream<S>
where S: Sync,

§

impl<S> Unpin for Stream<S>
where S: Unpin,

§

impl<S> UnwindSafe for Stream<S>
where S: UnwindSafe,

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