moved serialization to encoder
This commit is contained in:
parent
5d88a32095
commit
91ed6eeb14
1 changed files with 1 additions and 11 deletions
|
@ -1,13 +1,9 @@
|
|||
#![feature(async_closure)]
|
||||
|
||||
use std::pin::{pin, Pin};
|
||||
|
||||
use anyhow::{Context, Result};
|
||||
use common::{Command, Response, BAUDRATE};
|
||||
use framed::BoxPayload;
|
||||
use framed_codec::FramedCodec;
|
||||
use futures::{SinkExt, StreamExt};
|
||||
use tokio::io::AsyncBufReadExt;
|
||||
use tokio_serial::SerialPortBuilderExt;
|
||||
use tokio_util::codec::Framed;
|
||||
|
||||
|
@ -25,17 +21,11 @@ async fn main() -> Result<()> {
|
|||
Ok(postcard::from_bytes::<Response>(&data.ok().context("decode err")?)?)
|
||||
});
|
||||
|
||||
let mut write = write.with(move |data: Command| {
|
||||
let data = postcard::to_stdvec(&data).unwrap();
|
||||
async move {Ok(data)}
|
||||
});
|
||||
|
||||
|
||||
while let Some(data) = read.next().await {
|
||||
dbg!(data?);
|
||||
|
||||
|
||||
write.send(Command::Enable).await;
|
||||
write.send(Command::Enable).await?;
|
||||
}
|
||||
|
||||
Ok(())
|
||||
|
|
Loading…
Reference in a new issue