Struct thrift::transport::TBufferedTransport [] [src]

pub struct TBufferedTransport { /* fields omitted */ }

Transport that communicates with endpoints using a byte stream.

A TBufferedTransport maintains a fixed-size internal write buffer. All writes are made to this buffer and are sent to the wrapped transport only when TTransport::flush() is called. On a flush a fixed-length header with a count of the buffered bytes is written, followed by the bytes themselves.

A TBufferedTransport also maintains a fixed-size internal read buffer. On a call to TTransport::read(...) one full message - both fixed-length header and bytes - is read from the wrapped transport and buffered. Subsequent read calls are serviced from the internal buffer until it is exhausted, at which point the next full message is read from the wrapped transport.

Examples

Create and use a TBufferedTransport.

use std::cell::RefCell;
use std::rc::Rc;
use std::io::{Read, Write};
use thrift::transport::{TBufferedTransport, TTcpTransport, TTransport};

let mut t = TTcpTransport::new();
t.open("localhost:9090").unwrap();

let t = Rc::new(RefCell::new(Box::new(t) as Box<TTransport>));
let mut t = TBufferedTransport::new(t);

// read
t.read(&mut vec![0u8; 1]).unwrap();

// write
t.write(&[0x00]).unwrap();
t.flush().unwrap();

Methods

impl TBufferedTransport
[src]

Create a TBufferedTransport with default-sized internal read and write buffers that wraps an inner TTransport.

Create a TBufferedTransport with an internal read buffer of size read_buffer_capacity and an internal write buffer of size write_buffer_capacity that wraps an inner TTransport.

Trait Implementations

impl Read for TBufferedTransport
[src]

Pull some bytes from this source into the specified buffer, returning how many bytes were read. Read more

Read all bytes until EOF in this source, placing them into buf. Read more

Read all bytes until EOF in this source, placing them into buf. Read more

Read the exact number of bytes required to fill buf. Read more

Creates a "by reference" adaptor for this instance of Read. Read more

Transforms this Read instance to an Iterator over its bytes. Read more

Unstable (io)

: the semantics of a partial read/write of where errors happen is currently unclear and may change

Transforms this Read instance to an Iterator over chars. Read more

Creates an adaptor which will chain this stream with another. Read more

Creates an adaptor which will read at most limit bytes from it. Read more

impl Write for TBufferedTransport
[src]

Write a buffer into this object, returning how many bytes were written. Read more

Flush this output stream, ensuring that all intermediately buffered contents reach their destination. Read more

Attempts to write an entire buffer into this write. Read more

Writes a formatted string into this writer, returning any error encountered. Read more

Creates a "by reference" adaptor for this instance of Write. Read more