Skip to content

Bufferering types for embedded-io

Notifications You must be signed in to change notification settings

bugadani/buffered-io

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

37 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Buffer Types for embedded-io

CI crates.io docs.rs

The buffered-io crate implements buffering for the embedded-io/embedded-io-async Read and Write traits.

Example

#[cfg(feature = "async")]
tokio_test::block_on(async {
    use buffered_io::asynch::BufferedWrite;
    use embedded_io_async::Write;
    
    let uart_tx = Vec::new(); // The underlying uart peripheral implementing Write to where buffered bytes are written
    let mut write_buf = [0; 120];
    let mut buffering = BufferedWrite::new(uart_tx, &mut write_buf);
    buffering.write(b"hello").await.unwrap(); // This write is buffered
    buffering.write(b" ").await.unwrap(); // This write is also buffered
    buffering.write(b"world").await.unwrap(); // This write is also buffered
    buffering.flush().await.unwrap(); // The string "hello world" is written to uart in one write
})

About

Bufferering types for embedded-io

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Rust 100.0%