Struct buf_list::BufList

source ·
pub struct BufList { /* private fields */ }
Expand description

Data composed of a list of Bytes chunks.

For more, see the crate documentation.

Implementations§

Creates a new, empty, BufList.

Creates a new, empty, BufList with the given capacity.

Returns the total number of chunks in this BufList.

Examples
use buf_list::BufList;

let buf_list = vec![&b"hello"[..], &b"world"[..]].into_iter().collect::<BufList>();
assert_eq!(buf_list.num_chunks(), 2);

Returns the total number of bytes across all chunks.

Examples
use buf_list::BufList;

let buf_list = vec![&b"hello"[..], &b"world"[..]].into_iter().collect::<BufList>();
assert_eq!(buf_list.num_bytes(), 10);

Provides a reference to the chunk at the given index.

Examples
use buf_list::BufList;
use bytes::Bytes;

let buf_list = vec![&b"hello"[..], &b"world"[..]].into_iter().collect::<BufList>();
assert_eq!(buf_list.get_chunk(1), Some(&Bytes::from(&b"world"[..])));

Iterates over the chunks in this list.

Adds a new chunk to this list.

If the provided Buf is zero-length, it will not be added to the list.

Examples
use buf_list::BufList;
use bytes::{Buf, Bytes};

let mut buf_list = BufList::new();

// &'static [u8] implements Buf.
buf_list.push_chunk(&b"hello"[..]);
assert_eq!(buf_list.chunk(), &b"hello"[..]);

// Bytes also implements Buf.
buf_list.push_chunk(Bytes::from_static(&b"world"[..]));
assert_eq!(buf_list.num_chunks(), 2);

// A zero-length `Buf` will not be added to the list.
buf_list.push_chunk(Bytes::new());
assert_eq!(buf_list.num_chunks(), 2);

Trait Implementations§

Converts this type into a shared reference of the (usually inferred) input type.
Returns the number of bytes between the current position and the end of the buffer. Read more
Returns a slice starting at the current position and of length between 0 and Buf::remaining(). Note that this can return shorter slice (this allows non-continuous internal representation). Read more
Available on crate feature std only.
Fills dst with potentially multiple slices starting at self’s current position. Read more
Advance the internal cursor of the Buf Read more
Consumes len bytes inside self and returns new instance of Bytes with this data. Read more
Returns true if there are any more bytes to consume Read more
Copies bytes from self into dst. Read more
Gets an unsigned 8 bit integer from self. Read more
Gets a signed 8 bit integer from self. Read more
Gets an unsigned 16 bit integer from self in big-endian byte order. Read more
Gets an unsigned 16 bit integer from self in little-endian byte order. Read more
Gets an unsigned 16 bit integer from self in native-endian byte order. Read more
Gets a signed 16 bit integer from self in big-endian byte order. Read more
Gets a signed 16 bit integer from self in little-endian byte order. Read more
Gets a signed 16 bit integer from self in native-endian byte order. Read more
Gets an unsigned 32 bit integer from self in the big-endian byte order. Read more
Gets an unsigned 32 bit integer from self in the little-endian byte order. Read more
Gets an unsigned 32 bit integer from self in native-endian byte order. Read more
Gets a signed 32 bit integer from self in big-endian byte order. Read more
Gets a signed 32 bit integer from self in little-endian byte order. Read more
Gets a signed 32 bit integer from self in native-endian byte order. Read more
Gets an unsigned 64 bit integer from self in big-endian byte order. Read more
Gets an unsigned 64 bit integer from self in little-endian byte order. Read more
Gets an unsigned 64 bit integer from self in native-endian byte order. Read more
Gets a signed 64 bit integer from self in big-endian byte order. Read more
Gets a signed 64 bit integer from self in little-endian byte order. Read more
Gets a signed 64 bit integer from self in native-endian byte order. Read more
Gets an unsigned 128 bit integer from self in big-endian byte order. Read more
Gets an unsigned 128 bit integer from self in little-endian byte order. Read more
Gets an unsigned 128 bit integer from self in native-endian byte order. Read more
Gets a signed 128 bit integer from self in big-endian byte order. Read more
Gets a signed 128 bit integer from self in little-endian byte order. Read more
Gets a signed 128 bit integer from self in native-endian byte order. Read more
Gets an unsigned n-byte integer from self in big-endian byte order. Read more
Gets an unsigned n-byte integer from self in little-endian byte order. Read more
Gets an unsigned n-byte integer from self in native-endian byte order. Read more
Gets a signed n-byte integer from self in big-endian byte order. Read more
Gets a signed n-byte integer from self in little-endian byte order. Read more
Gets a signed n-byte integer from self in native-endian byte order. Read more
Gets an IEEE754 single-precision (4 bytes) floating point number from self in big-endian byte order. Read more
Gets an IEEE754 single-precision (4 bytes) floating point number from self in little-endian byte order. Read more
Gets an IEEE754 single-precision (4 bytes) floating point number from self in native-endian byte order. Read more
Gets an IEEE754 double-precision (8 bytes) floating point number from self in big-endian byte order. Read more
Gets an IEEE754 double-precision (8 bytes) floating point number from self in little-endian byte order. Read more
Gets an IEEE754 double-precision (8 bytes) floating point number from self in native-endian byte order. Read more
Creates an adaptor which will read at most limit bytes from self. Read more
Creates an adaptor which will chain this buffer with another. Read more
Available on crate feature std only.
Creates an adaptor which implements the Read trait for self. Read more
Returns a copy of the value. Read more
Performs copy-assignment from source. Read more
Formats the value using the given formatter. Read more
Returns the “default value” for a type. Read more
Extends a collection with the contents of an iterator. Read more
🔬This is a nightly-only experimental API. (extend_one)
Extends a collection with exactly one element.
🔬This is a nightly-only experimental API. (extend_one)
Reserves capacity in a collection for the given number of additional elements. Read more
Converts to this type from the input type.
Creates a value from an iterator. Read more
The type of the elements being iterated over.
Which kind of iterator are we turning this into?
Creates an iterator from a value. Read more
The type of the elements being iterated over.
Which kind of iterator are we turning this into?
Creates an iterator from a value. Read more

Auto Trait Implementations§

Blanket Implementations§

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The resulting type after obtaining ownership.
Creates owned data from borrowed data, usually by cloning. Read more
Uses borrowed data to replace owned data, usually by cloning. Read more
The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.