kvarn_async::prelude::bytes::buf

Struct Chain

pub struct Chain<T, U> { /* private fields */ }
Expand description

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};

let mut buf = (&b"hello "[..])
    .chain(&b"world"[..]);

let full: Bytes = buf.copy_to_bytes(11);
assert_eq!(full[..], b"hello world"[..]);

Implementations§

§

impl<T, U> Chain<T, U>

pub fn first_ref(&self) -> &T

Gets a reference to the first underlying Buf.

§Examples
use bytes::Buf;

let buf = (&b"hello"[..])
    .chain(&b"world"[..]);

assert_eq!(buf.fi