Trait bytes::Source
[−]
[src]
pub trait Source {
fn copy_to_buf<B: BufMut>(self, buf: &mut B);
}A value that writes bytes from itself into a BufMut.
Values that implement Source are used as an argument to
BufMut::put.
Examples
use bytes::{BufMut, Source}; struct Repeat { num: usize, str: String, } impl Source for Repeat { fn copy_to_buf<B: BufMut>(self, buf: &mut B) { for _ in 0..self.num { buf.put(&self.str); } } } let mut dst = vec![]; dst.put(Repeat { num: 3, str: "hello".into(), }); assert_eq!(*dst, b"hellohellohello"[..]);