[−][src]Struct bytes::buf::ext::Chain
A Chain
sequences two buffers.
Chain
is an adapter that links two underlying buffers and provides a
continuous view across both buffers. It is able to sequence either immutable
buffers (Buf
values) or mutable buffers (BufMut
values).
This struct is generally created by calling Buf::chain
. Please see that
function's documentation for more detail.
Examples
use bytes::{Bytes, Buf, buf::BufExt}; let mut buf = (&b"hello "[..]) .chain(&b"world"[..]); let full: Bytes = buf.to_bytes(); assert_eq!(full[..], b"hello world"[..]);
Implementations
impl<T, U> Chain<T, U>
[src][−]
pub fn new(a: T, b: U) -> Chain<T, U>
[src][−]
Creates a new Chain
sequencing the provided values.
pub fn first_ref(&self) -> &T
[src][−]
Gets a reference to the first underlying Buf
.
Examples
use bytes::buf::BufExt; let buf = (&b"hello"[..]) .chain(&b"world"[..]); assert_eq!(buf.first_ref()[..], b"hello"[..]);
pub fn first_mut(&mut self) -> &mut T
[src][−]
Gets a mutable reference to the first underlying Buf
.
Examples
use bytes::{Buf, buf::BufExt}; let mut buf = (&b"hello"[..]) .chain(&b"world"[..]); buf.first_mut().advance(1); let full = buf.to_bytes(); assert_eq!(full, b"elloworld"[..]);
pub fn last_ref(&self) -> &U
[src][−]
Gets a reference to the last underlying Buf
.
Examples
use bytes::buf::BufExt; let buf = (&b"hello"[..]) .chain(&b"world"[..]); assert_eq!(buf.last_ref()[..], b"world"[..]);
pub fn last_mut(&mut self) -> &mut U
[src][−]
Gets a mutable reference to the last underlying Buf
.
Examples
use bytes::{Buf, buf::BufExt}; let mut buf = (&b"hello "[..]) .chain(&b"world"[..]); buf.last_mut().advance(1); let full = buf.to_bytes(); assert_eq!(full, b"hello orld"[..]);
pub fn into_inner(self) -> (T, U)
[src][−]
Consumes this Chain
, returning the underlying values.
Examples
use bytes::buf::BufExt; let chain = (&b"hello"[..]) .chain(&b"world"[..]); let (first, last) = chain.into_inner(); assert_eq!(first[..], b"hello"[..]); assert_eq!(last[..], b"world"[..]);
Trait Implementations
impl<T, U> Buf for Chain<T, U> where
T: Buf,
U: Buf,
[src][+]
T: Buf,
U: Buf,
impl<T, U> BufMut for Chain<T, U> where
T: BufMut,
U: BufMut,
[src][+]
T: BufMut,
U: BufMut,
impl<T: Debug, U: Debug> Debug for Chain<T, U>
[src][+]
impl<T, U> IntoIterator for Chain<T, U> where
T: Buf,
U: Buf,
[src][+]
T: Buf,
U: Buf,
Auto Trait Implementations
impl<T, U> RefUnwindSafe for Chain<T, U> where
T: RefUnwindSafe,
U: RefUnwindSafe,
T: RefUnwindSafe,
U: RefUnwindSafe,
impl<T, U> Send for Chain<T, U> where
T: Send,
U: Send,
T: Send,
U: Send,
impl<T, U> Sync for Chain<T, U> where
T: Sync,
U: Sync,
T: Sync,
U: Sync,
impl<T, U> Unpin for Chain<T, U> where
T: Unpin,
U: Unpin,
T: Unpin,
U: Unpin,
impl<T, U> UnwindSafe for Chain<T, U> where
T: UnwindSafe,
U: UnwindSafe,
T: UnwindSafe,
U: UnwindSafe,
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src][+]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src][+]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src][+]
T: ?Sized,
impl<B> BufExt for B where
B: Buf + ?Sized,
[src][+]
B: Buf + ?Sized,
impl<B> BufMutExt for B where
B: BufMut + ?Sized,
[src][+]
B: BufMut + ?Sized,
impl<T> From<T> for T
[src][+]
impl<T, U> Into<U> for T where
U: From<T>,
[src][+]
U: From<T>,
impl<I> IntoIterator for I where
I: Iterator,
[src][+]
I: Iterator,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src][+]
U: Into<T>,
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src][+]
U: TryFrom<T>,