pub fn new_stack_buffer<const N: usize>() -> Buffer<[u8; N]> ⓘ
Examples found in repository?
examples/stack_buffer.rs (line 9)
6fn main () {
7
8 // Create a new buffern with an array as byte source on the stack
9 let mut buffer = new_stack_buffer::<1024>();
10
11 // Write some bytes to buffer
12 buffer.write_all("hello world".as_bytes()).unwrap();
13
14 // read the bytes again
15 let mut buf = [0; 128];
16 let bytes_read = buffer.read(&mut buf).unwrap();
17
18 assert_eq!("hello world".as_bytes(), &buf[..bytes_read]);
19
20}