Struct asyncio::StreamBuf [] [src]

pub struct StreamBuf { /* fields omitted */ }

Automatically resizing buffer.

Methods

impl StreamBuf
[src]

Returns a new StreamBuf.

Equivalent to with_max_len(usize::max_len())

Examples

use asyncio::StreamBuf;

let mut sbuf = StreamBuf::new();

Returns a new StreamBuf with the max length of the allocatable size.

Examples

use asyncio::StreamBuf;

let mut sbuf = StreamBuf::with_max_len(1024);

Returns an allocated size of the buffer.

Examples

use asyncio::StreamBuf;

let mut sbuf = StreamBuf::new();
assert_eq!(sbuf.capacity(), 0);

Clears the buffer, removing all values.

Examples

use asyncio::StreamBuf;

let mut sbuf = StreamBuf::from(vec![1,2,3]);
sbuf.clear();
assert_eq!(sbuf.is_empty(), true);

Remove characters from the input sequence.

Examples

use asyncio::StreamBuf;

let mut sbuf = StreamBuf::from(vec![1,2,3]);
assert_eq!(sbuf.len(), 3);
sbuf.consume(3);
assert_eq!(sbuf.len(), 0);

Move characters from the output sequence to the input sequence.

Examples

use asyncio::StreamBuf;

let mut sbuf = StreamBuf::new();
let _ = sbuf.prepare(256);
assert_eq!(sbuf.len(), 0);
sbuf.commit(3);
assert_eq!(sbuf.len(), 3);

Returns true if the empty buffer.

Examples

use asyncio::StreamBuf;

let sbuf = StreamBuf::new();
assert!(sbuf.is_empty());

Returns a length of the input sequence.

Examples

use asyncio::StreamBuf;

let sbuf = StreamBuf::from(vec![1,2,3]);
assert_eq!(sbuf.len(), 3);

Returns a maximum length of the StreamBuf.

Examples

use asyncio::StreamBuf;

let sbuf = StreamBuf::new();
assert_eq!(sbuf.max_len(), usize::max_value());

Returns a &mut [u8] that represents a output sequence.

Examples

use asyncio::StreamBuf;

let mut sbuf = StreamBuf::with_max_len(8);
assert_eq!(sbuf.prepare(5).unwrap().len(), 5);
sbuf.commit(5);
assert_eq!(sbuf.prepare(5).unwrap().len(), 3);

Returns a &mut [u8] that represents a output sequence.

Examples

use asyncio::StreamBuf;

let mut sbuf = StreamBuf::with_max_len(8);
assert_eq!(sbuf.prepare_exact(5).unwrap().len(), 5);
sbuf.commit(5);
assert!(sbuf.prepare_exact(5).is_err());

Returns a &[u8] that represents the input sequence.

Returns a &mut [u8] that represents the input sequence.

Trait Implementations

impl Clone for StreamBuf
[src]

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

impl Debug for StreamBuf
[src]

Formats the value using the given formatter.

impl Default for StreamBuf
[src]

Returns the "default value" for a type. Read more

impl AsRef<StreamBuf> for StreamBuf
[src]

Performs the conversion.

impl AsMut<StreamBuf> for StreamBuf
[src]

Performs the conversion.

impl AsRef<[u8]> for StreamBuf
[src]

Performs the conversion.

impl AsMut<[u8]> for StreamBuf
[src]

Performs the conversion.

impl From<Vec<u8>> for StreamBuf
[src]

Performs the conversion.

impl From<CString> for StreamBuf
[src]

Performs the conversion.

impl<'a> From<&'a [u8]> for StreamBuf
[src]

Performs the conversion.

impl<'a> From<&'a str> for StreamBuf
[src]

Performs the conversion.

impl Read for StreamBuf
[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 StreamBuf
[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