[][src]Struct thrift::transport::TBufferChannel

pub struct TBufferChannel { /* fields omitted */ }

In-memory read and write channel with fixed-size read and write buffers.

On a write bytes are written to the internal write buffer. Writes are no longer accepted once this buffer is full. Callers must empty_write_buffer() before subsequent writes are accepted.

You can set readable bytes in the internal read buffer by filling it with set_readable_bytes(...). Callers can then read until the buffer is depleted. No further reads are accepted until the internal read buffer is replenished again.

Methods

impl TBufferChannel[src]

Important traits for TBufferChannel
pub fn with_capacity(
    read_capacity: usize,
    write_capacity: usize
) -> TBufferChannel
[src]

Constructs a new, empty TBufferChannel with the given read buffer capacity and write buffer capacity.

pub fn read_bytes(&self) -> Vec<u8>[src]

Return a copy of the bytes held by the internal read buffer. Returns an empty vector if no readable bytes are present.

pub fn empty_read_buffer(&mut self)[src]

Reset the number of readable bytes to zero.

Subsequent calls to read will return nothing.

pub fn set_readable_bytes(&mut self, buf: &[u8]) -> usize[src]

Copy bytes from the source buffer buf into the internal read buffer, overwriting any existing bytes. Returns the number of bytes copied, which is min(buf.len(), internal_read_buf.len()).

pub fn write_bytes(&self) -> Vec<u8>[src]

Return a copy of the bytes held by the internal write buffer. Returns an empty vector if no bytes were written.

pub fn empty_write_buffer(&mut self)[src]

Resets the internal write buffer, making it seem like no bytes were written. Calling write_buffer after this returns an empty vector.

pub fn copy_write_buffer_to_read_buffer(&mut self)[src]

Overwrites the contents of the read buffer with the contents of the write buffer. The write buffer is emptied after this operation.

Trait Implementations

impl TIoChannel for TBufferChannel[src]

impl Debug for TBufferChannel[src]

impl Read for TBufferChannel[src]

impl Write for TBufferChannel[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]