[][src]Struct rdp::core::tpkt::Client

pub struct Client<S> { /* fields omitted */ }

Client Context of TPKT layer

Example

use std::io::Cursor;
use rdp::model::link::{Link, Stream};
use rdp::core::tpkt::Client;
let mut stream = Cursor::new(vec![]);
let tpkt_client = Client::new(Link::new(Stream::Raw(stream)));

Methods

impl<S: Read + Write> Client<S>[src]

pub fn new(transport: Link<S>) -> Self[src]

Ctor of TPKT client layer

pub fn write<T: 'static>(&mut self, message: T) -> RdpResult<()> where
    T: Message
[src]

Send a message to the link layer with appropriate header Move to avoid copy

Example

#[macro_use]
    let mut tpkt = tpkt::Client::new(link::Link::new(link::Stream::Raw(Cursor::new(vec![]))));
    tpkt.write(trame![U16::BE(4), U32::LE(3)]).unwrap();
    // get_link and get_stream are not available on Crate
    // only use for integration test [features = integration]
    if let link::Stream::Raw(e) = tpkt.get_link().get_stream() {
        assert_eq!(e.into_inner(), [3, 0, 0, 10, 0, 4, 3, 0, 0, 0])
    }
    else {
        panic!("Must not happen")
    }
}

pub fn read(&mut self) -> RdpResult<Payload>[src]

Read a payload from the underlying layer Check the tpkt header and provide a well formed payload

Example

use rdp::core::tpkt;
use rdp::model::link;
use std::io::Cursor;
let mut tpkt = tpkt::Client::new(link::Link::new(link::Stream::Raw(Cursor::new(vec![3, 0, 0, 10, 0, 4, 3, 0, 0, 0]))));
if let tpkt::Payload::Raw(c) = tpkt.read().unwrap() {
    assert_eq!(c.into_inner(), vec![0, 4, 3, 0, 0, 0])
}
else {
    panic!("unexpected result")
}

tpkt = tpkt::Client::new(link::Link::new(link::Stream::Raw(Cursor::new(vec![0, 6, 0, 0, 0, 0]))));
if let tpkt::Payload::FastPath(_, c) = tpkt.read().unwrap() {
    assert_eq!(c.into_inner(), vec![0, 0, 0, 0])
}
else {
    panic!("unexpected result")
}

tpkt = tpkt::Client::new(link::Link::new(link::Stream::Raw(Cursor::new(vec![0, 0x80, 7, 0, 0, 0, 0]))));
if let tpkt::Payload::FastPath(_, c) = tpkt.read().unwrap() {
    assert_eq!(c.into_inner(), vec![0, 0, 0, 0])
}
else {
    panic!("unexpected result")
}

pub fn start_ssl(self, check_certificate: bool) -> RdpResult<Client<S>>[src]

This function transform the link layer with raw data stream into a SSL data stream

Example

use std::net::{SocketAddr, TcpStream};
use rdp::core::tpkt;
use rdp::model::link;
let addr = "127.0.0.1:3389".parse::<SocketAddr>().unwrap();
let mut tcp = TcpStream::connect(&addr).unwrap();
let mut tpkt = tpkt::Client::new(link::Link::new(link::Stream::Raw(tcp)));
let mut tpkt_ssl = tpkt.start_ssl(false).unwrap();

pub fn start_nla(
    self,
    check_certificate: bool,
    authentication_protocol: &mut dyn AuthenticationProtocol,
    restricted_admin_mode: bool
) -> RdpResult<Client<S>>
[src]

This function is used when NLA (Network Level Authentication) Authentication is negotiated

Example

use std::net::{SocketAddr, TcpStream};
use rdp::core::tpkt;
use rdp::nla::ntlm::Ntlm;
use rdp::model::link;
let addr = "127.0.0.1:3389".parse::<SocketAddr>().unwrap();
let mut tcp = TcpStream::connect(&addr).unwrap();
let mut tpkt = tpkt::Client::new(link::Link::new(link::Stream::Raw(tcp)));
let mut tpkt_nla = tpkt.start_nla(false, &mut Ntlm::new("domain".to_string(), "username".to_string(), "password".to_string()), false);

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

Shutdown current connection

Auto Trait Implementations

impl<S> RefUnwindSafe for Client<S> where
    S: RefUnwindSafe

impl<S> Send for Client<S> where
    S: Send

impl<S> Sync for Client<S> where
    S: Sync

impl<S> Unpin for Client<S> where
    S: Unpin

impl<S> UnwindSafe for Client<S> where
    S: UnwindSafe

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>,