Found some bugs
This commit is contained in:
1 parent
ec73c54276
commit
8b593939e5
3 files changed
+13
-6
No files matched your search
+8
-4
@@ -2,11 +2,11 @@ mod handling;
|
||||
mod testing;
|
||||
|
||||
use litemap::LiteMap;
|
||||
use minicbor::Decoder;
|
||||
use minicbor::data::Type;
|
||||
use minicbor::decode::Error;
|
||||
use minicbor::Decoder;
|
||||
use std::collections::HashMap;
|
||||
use std::fmt::{Display, Formatter };
|
||||
use std::fmt::{Display, Formatter};
|
||||
use std::io::Write;
|
||||
|
||||
pub enum Command {
|
||||
@@ -73,7 +73,10 @@ impl Display for Line {
|
||||
|
||||
impl From<&[u8]> for Command {
|
||||
fn from(value: &[u8]) -> Self {
|
||||
parse_command(value).unwrap_or(Command::Unknown)
|
||||
parse_command(value).unwrap_or_else(|e| {
|
||||
println!("{}", e);
|
||||
Command::Unknown
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
@@ -87,6 +90,7 @@ fn parse_command(data: &[u8]) -> Result<Command, Error> {
|
||||
return Ok(Command::Set(id, value));
|
||||
}
|
||||
if data.starts_with(b"PUSH:") {
|
||||
println!("{}", String::from_utf8_lossy(data));
|
||||
let payload = &data[b"PUSH:".len()..];
|
||||
let mut decoder = Decoder::new(&payload);
|
||||
decoder.array()?;
|
||||
@@ -152,7 +156,7 @@ pub struct NoteContext {
|
||||
|
||||
impl NoteContext {
|
||||
pub fn default() -> Self {
|
||||
Self{
|
||||
Self {
|
||||
entries: Default::default(),
|
||||
output: Box::new(std::io::stdout()),
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user