Skip to content

Commit

Permalink
Ran cargo fmt
Browse files Browse the repository at this point in the history
Don't be like me, add the checks to a git hook
  • Loading branch information
george-cosma committed Aug 24, 2023
1 parent 53c7786 commit 8930527
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions src/serial_interface.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,15 @@ use std::{io, str};

use tokio_util::codec::{Decoder, Encoder, Framed};

use bytes::{BufMut, BytesMut, Buf};
use bytes::{Buf, BufMut, BytesMut};
use console::Term;
use tokio_serial::SerialPortBuilderExt;
use tokio_serial::SerialStream;

pub struct LineCodec;

impl LineCodec {
fn clean_input(input: &str ) -> String {
fn clean_input(input: &str) -> String {
input.replace('\n', "\r\n")
}
}
Expand All @@ -29,7 +29,7 @@ impl Decoder for LineCodec {
}

// Read everything you can, and interpret it as a string.
match str::from_utf8(&source) {
match str::from_utf8(source) {
Ok(utf8_string) => {
let output = LineCodec::clean_input(utf8_string);
source.clear();
Expand All @@ -49,8 +49,14 @@ impl Decoder for LineCodec {
let output = LineCodec::clean_input(utf8_string);
source.advance(index);
Ok(Some(output))
},
Err(_) => Err(io::Error::new(io::ErrorKind::InvalidData, format!("Couldn't parse input as UTF8. Last valid index: {}. Buffer: {:?}",index,source))),
}
Err(_) => Err(io::Error::new(
io::ErrorKind::InvalidData,
format!(
"Couldn't parse input as UTF8. Last valid index: {}. Buffer: {:?}",
index, source
),
)),
}
}
}
Expand Down

0 comments on commit 8930527

Please sign in to comment.