Trait fluvio::dataplane::core::api::core::bytes::BufMutExt[][src]

pub trait BufMutExt: BufMut {
    pub fn limit(self, limit: usize) -> Limit<Self> { ... }
pub fn writer(self) -> Writer<Self> { ... }
pub fn chain_mut<U>(self, next: U) -> Chain<Self, U>
    where
        U: BufMut
, { ... } }

Extra methods for implementations of BufMut.

Provided methods

pub fn limit(self, limit: usize) -> Limit<Self>[src]

Creates an adaptor which can write at most limit bytes to self.

Examples

use bytes::{BufMut, buf::BufMutExt};

let arr = &mut [0u8; 128][..];
assert_eq!(arr.remaining_mut(), 128);

let dst = arr.limit(10);
assert_eq!(dst.remaining_mut(), 10);

pub fn writer(self) -> Writer<Self>[src]

Creates an adaptor which implements the Write trait for self.

This function returns a new value which implements Write by adapting the Write trait functions to the BufMut trait functions. Given that BufMut operations are infallible, none of the Write functions will return with Err.

Examples

use bytes::buf::BufMutExt;
use std::io::Write;

let mut buf = vec![].writer();

let num = buf.write(&b"hello world"[..]).unwrap();
assert_eq!(11, num);

let buf = buf.into_inner();

assert_eq!(*buf, b"hello world"[..]);

pub fn chain_mut<U>(self, next: U) -> Chain<Self, U> where
    U: BufMut
[src]

Creates an adapter which will chain this buffer with another.

The returned BufMut instance will first write to all bytes from self. Afterwards, it will write to next.

Examples

use bytes::{BufMut, buf::BufMutExt};

let mut a = [0u8; 5];
let mut b = [0u8; 6];

let mut chain = (&mut a[..]).chain_mut(&mut b[..]);

chain.put_slice(b"hello world");

assert_eq!(&a[..], b"hello");
assert_eq!(&b[..], b" world");
Loading content...

Implementors

impl<B> BufMutExt for B where
    B: BufMut + ?Sized
[src]

Loading content...