Skip to content

Commit

Permalink
fix(defmt): fix wrong defmt::Fromat impls
Browse files Browse the repository at this point in the history
Signed-off-by: Jad K. Haddad <jadkhaddad@gmail.com>
  • Loading branch information
JadKHaddad committed Nov 2, 2024
1 parent c90b417 commit 4fb3294
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 9 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,8 @@ jobs:
- name: Clippy -- tracing
run: cargo clippy --no-default-features --features="tracing" -- -D warnings

- name: Clippy -- binode
run: cargo clippy --no-default-features --features="binode" -- -D warnings
- name: Clippy -- bincode
run: cargo clippy --no-default-features --features="bincode" -- -D warnings

# Test

Expand Down
8 changes: 4 additions & 4 deletions src/codec/bincode.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ pub enum BincodeDecodeError {
impl defmt::Format for BincodeDecodeError {
fn format(&self, f: defmt::Formatter) {
match self {
Self::Decode(err) => f.error().field("Decode", err),
Self::Decode(_) => defmt::write!(f, "Decode error"),
}
}
}
Expand Down Expand Up @@ -98,9 +98,9 @@ pub enum BincodeEncodeError {
impl defmt::Format for BincodeEncodeError {
fn format(&self, f: defmt::Formatter) {
match self {
Self::BufferTooSmall => f.error().field("Buffer too small", &true),
Self::Encode(err) => f.error().field("Encode", err),
Self::PayloadTooLarge => f.error().field("Payload too large", &true),
Self::BufferTooSmall => defmt::write!(f, "Buffer too small"),
Self::Encode(_) => defmt::write!(f, "Encode error"),
Self::PayloadTooLarge => defmt::write!(f, "Payload too large"),
}
}
}
Expand Down
8 changes: 5 additions & 3 deletions src/framed_read.rs
Original file line number Diff line number Diff line change
Expand Up @@ -567,7 +567,6 @@ impl<const N: usize, D, R> FramedRead<N, D, R> {
mod test {
extern crate std;

use core::str::FromStr;
use std::vec::Vec;

use futures::{pin_mut, SinkExt, StreamExt};
Expand All @@ -581,7 +580,7 @@ mod test {
error,
test::init_tracing,
tokio::Compat,
AnyDelimiterCodecOwned, BincodeCodecOwned, FramedWrite, LengthCodec, LengthCodecOwned,
AnyDelimiterCodecOwned, FramedWrite, LengthCodec, LengthCodecOwned,
};

use super::*;
Expand Down Expand Up @@ -866,9 +865,12 @@ mod test {
#[tokio::test]
#[cfg(feature = "bincode")]
async fn stream_sink_bincode() {
use crate::test::bincode::BincodeMessage;
use core::str::FromStr;

use bincode::serde::Compat as BincodeSerdeCompat;

use crate::{test::bincode::BincodeMessage, BincodeCodecOwned};

init_tracing();

let items: Vec<BincodeMessage> = std::vec![
Expand Down

0 comments on commit 4fb3294

Please sign in to comment.