stack_buffer/
stack_buffer.rs

1use embytes_buffer::new_stack_buffer;
2use embedded_io::{Read, Write};
3
4
5
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}
21