[][src]Struct thrift::transport::TTcpChannel

pub struct TTcpChannel { /* fields omitted */ }

Bidirectional TCP/IP channel.

Examples

Create a TTcpChannel.

use std::io::{Read, Write};
use thrift::transport::TTcpChannel;

let mut c = TTcpChannel::new();
c.open("localhost:9090").unwrap();

let mut buf = vec![0u8; 4];
c.read(&mut buf).unwrap();
c.write(&vec![0, 1, 2]).unwrap();

Create a TTcpChannel by wrapping an existing TcpStream.

use std::io::{Read, Write};
use std::net::TcpStream;
use thrift::transport::TTcpChannel;

let stream = TcpStream::connect("127.0.0.1:9189").unwrap();

// no need to call c.open() since we've already connected above
let mut c = TTcpChannel::with_stream(stream);

let mut buf = vec![0u8; 4];
c.read(&mut buf).unwrap();
c.write(&vec![0, 1, 2]).unwrap();

Methods

impl TTcpChannel[src]

Important traits for TTcpChannel
pub fn new() -> TTcpChannel[src]

Create an uninitialized TTcpChannel.

The returned instance must be opened using TTcpChannel::open(...) before it can be used.

Important traits for TTcpChannel
pub fn with_stream(stream: TcpStream) -> TTcpChannel[src]

Create a TTcpChannel that wraps an existing TcpStream.

The passed-in stream is assumed to have been opened before being wrapped by the created TTcpChannel instance.

pub fn open(&mut self, remote_address: &str) -> Result<()>[src]

Connect to remote_address, which should have the form host:port.

pub fn close(&mut self) -> Result<()>[src]

Shut down this channel.

Both send and receive halves are closed, and this instance can no longer be used to communicate with another endpoint.

Trait Implementations

impl TIoChannel for TTcpChannel[src]

impl Default for TTcpChannel[src]

impl Debug for TTcpChannel[src]

impl Read for TTcpChannel[src]

impl Write for TTcpChannel[src]

Auto Trait Implementations

Blanket Implementations

impl<T> TReadTransport for T where
    T: Read
[src]

impl<T> TWriteTransport for T where
    T: Write
[src]

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

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

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<T> Borrow<T> for T where
    T: ?Sized
[src]

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

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

impl<R> ReadBytesExt for R where
    R: Read + ?Sized
[src]

impl<W> WriteBytesExt for W where
    W: Write + ?Sized
[src]

impl<R> VarIntReader for R where
    R: Read
[src]

impl<R> FixedIntReader for R where
    R: Read
[src]

impl<Inner> VarIntWriter for Inner where
    Inner: Write
[src]

impl<W> FixedIntWriter for W where
    W: Write
[src]