Skip to content

Commit

Permalink
Merge branch 'FactbirdHQ:master' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
dragonnn authored Aug 14, 2024
2 parents 1ca6aa1 + 2768e5a commit 6a5902e
Show file tree
Hide file tree
Showing 30 changed files with 617 additions and 167 deletions.
20 changes: 7 additions & 13 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ jobs:
uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: nightly
toolchain: stable
override: true
components: rustfmt

Expand All @@ -50,7 +50,7 @@ jobs:
# uses: actions-rs/toolchain@v1
# with:
# profile: minimal
# toolchain: nightly
# toolchain: stable
# override: true

# - name: Install tomlfmt
Expand All @@ -77,7 +77,7 @@ jobs:
uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: nightly
toolchain: stable
override: true
components: clippy

Expand All @@ -93,13 +93,7 @@ jobs:
strategy:
matrix:
target: ["x86_64-unknown-linux-gnu", "thumbv6m-none-eabi"]
features:
[
"",
"derive",
"async",
"derive,async",
]
features: ["", "derive"]
include:
- target: "x86_64-unknown-linux-gnu"
extra_features: "std,log"
Expand All @@ -113,7 +107,7 @@ jobs:
uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: nightly
toolchain: stable
target: thumbv6m-none-eabi
override: true

Expand All @@ -133,11 +127,11 @@ jobs:
uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: nightly
toolchain: stable
target: thumbv6m-none-eabi
override: true
- name: Library tests
uses: actions-rs/cargo@v1
with:
command: test
args: --workspace --features std,heapless
args: --workspace --features std,heapless,string_errors
3 changes: 1 addition & 2 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@
// with these changes RA will call `cargo check --bins` on save
"rust-analyzer.checkOnSave.allTargets": false,
"rust-analyzer.cargo.target": "thumbv6m-none-eabi",
"rust-analyzer.cargo.features": ["async"],
"rust-analyzer.diagnostics.disabled": [
"unresolved-import"
]
}
}
5 changes: 0 additions & 5 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,3 @@ incremental = false
lto = 'fat'
opt-level = "s" # <-
overflow-checks = false # <-

[patch.crates-io]
embassy-executor = { version = "0.3", git = "https://github.com/embassy-rs/embassy", rev = "5f7cd82" }
embassy-rp = { version = "0.1", git = "https://github.com/embassy-rs/embassy", rev = "5f7cd82" }
embassy-time = { version = "0.2", git = "https://github.com/embassy-rs/embassy", rev = "5f7cd82" }
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ This workspace uses `cargo-release` to do workspace releases to crates.io. It ca

## About

- Minimum rustc version 1.52
- Minimum rustc version 1.79
- Tested and built using stable toolchain

## Supported Crates
Expand Down Expand Up @@ -109,8 +109,8 @@ The following dependent crates provide platform-agnostic device drivers built on
- `log`: Disabled by default. Enable log statements on various log levels to aid debugging. Powered by `log`.
- `defmt`: Disabled by default. Enable defmt log statements on various log levels to aid debugging. Powered by `defmt`.
- `custom-error-messages`: Disabled by default. Allows errors to contain custom error messages up to 64 characters, parsed by `AtDigest::custom_error`.
- `async`: Enable the async interfaces on both `Ingress` and `Client`.
- `hex_str_arrays`: Disabled by default. Needs `#![feature(generic_const_exprs)]` Nightly feature. This allows for hex strings to be serialized to a fix-width byte array.
- `hex_str_arrays`: Disabled by default. Needs `#![feature(generic_const_exprs)]` Nightly feature. This allows for hex strings to be serialized to a fix-width byte array.
- `heapless`: Enable heapless feature on `serde_at`. This enables heapless support and adds some specialized parsing structs.

## Chat / Getting Help

Expand Down
25 changes: 14 additions & 11 deletions atat/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "atat"
version = "0.20.0"
version = "0.23.0"
authors = ["Mathias Koch <mk@blackbird.online>"]
description = "AT Parser for serial based device crates"
readme = "../README.md"
Expand All @@ -19,35 +19,38 @@ name = "atat"

[dependencies]
embedded-io = "0.6.0"
embedded-io-async = { version = "0.6.0", optional = true }
futures = { version = "0.3", default-features = false, optional = true }
embassy-sync = "0.5"
embassy-time = "0.2"
embedded-io-async = "0.6.0"
futures = { version = "0.3", default-features = false }
embassy-sync = "0.6"
embassy-time = "0.3"
heapless = { version = "^0.8", features = ["serde"] }
serde_at = { path = "../serde_at", version = "^0.20.0", optional = true }
atat_derive = { path = "../atat_derive", version = "^0.20.0", optional = true }
serde_bytes = { version = "0.11.5", default-features = false, optional = true }
serde_at = { path = "../serde_at", version = "^0.23.0", optional = true }
atat_derive = { path = "../atat_derive", version = "^0.23.0", optional = true }
serde_bytes = { version = "0.11.14", default-features = false, optional = true }
heapless-bytes = { version = "0.3.0", optional = true }


nom = { version = "^7.1", default-features = false }

log = { version = "^0.4", default-features = false, optional = true }
defmt = { version = "^0.3", optional = true }

[dev-dependencies]
embassy-time = { version = "0.2", features = ["std", "generic-queue"] }
embassy-time = { version = "0.3", features = ["std", "generic-queue"] }
critical-section = { version = "1.1", features = ["std"] }
serde_at = { path = "../serde_at", version = "^0.20.0", features = [
serde_at = { path = "../serde_at", version = "^0.23.0", features = [
"heapless",
] }
tokio = { version = "1", features = ["macros", "rt"] }
static_cell = { version = "2.0.0" }

[features]
default = ["derive", "bytes"]
defmt = ["dep:defmt", "embedded-io-async/defmt-03", "heapless/defmt-03"]
derive = ["atat_derive", "serde_at"]
bytes = ["heapless-bytes", "serde_bytes"]
custom-error-messages = []
async = ["embedded-io-async", "futures"]
std = ["serde_at/std", "nom/std", "embassy-time/std", "embedded-io/std"]
hex_str_arrays = []
heapless = ["serde_at/heapless"]
string_errors = []
15 changes: 11 additions & 4 deletions atat/src/asynch/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use crate::{
response_slot::{ResponseSlot, ResponseSlotGuard},
AtatCmd, Config, Error, Response,
};
use embassy_time::{Duration, Instant, TimeoutError, Timer};
use embassy_time::{with_timeout, Duration, Instant, TimeoutError, Timer};
use embedded_io_async::Write;
use futures::{
future::{select, Either},
Expand Down Expand Up @@ -48,11 +48,18 @@ impl<'a, W: Write, const INGRESS_BUF_SIZE: usize> Client<'a, W, INGRESS_BUF_SIZE
self.res_slot.reset();

// Write request
self.writer
.write_all(&self.buf[..len])
with_timeout(
self.config.tx_timeout,
self.writer.write_all(&self.buf[..len]),
)
.await
.map_err(|_| Error::Timeout)?
.map_err(|_| Error::Write)?;

with_timeout(self.config.flush_timeout, self.writer.flush())
.await
.map_err(|_| Error::Timeout)?
.map_err(|_| Error::Write)?;
self.writer.flush().await.map_err(|_| Error::Write)?;

self.start_cooldown_timer();
Ok(())
Expand Down
11 changes: 11 additions & 0 deletions atat/src/asynch/mod.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
mod client;
mod simple_client;

pub use client::Client;
pub use simple_client::SimpleClient;

use crate::{AtatCmd, Error};

Expand Down Expand Up @@ -33,3 +35,12 @@ pub trait AtatClient {
Err(Error::Timeout)
}
}

impl<T> AtatClient for &mut T
where
T: AtatClient,
{
async fn send<Cmd: AtatCmd>(&mut self, cmd: &Cmd) -> Result<Cmd::Response, Error> {

Check warning on line 43 in atat/src/asynch/mod.rs

View workflow job for this annotation

GitHub Actions / clippy

future cannot be sent between threads safely

warning: future cannot be sent between threads safely --> atat/src/asynch/mod.rs:43:5 | 43 | async fn send<Cmd: AtatCmd>(&mut self, cmd: &Cmd) -> Result<Cmd::Response, Error> { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ future returned by `send` is not `Send` | note: future is not `Send` as it awaits another future which is not `Send` --> atat/src/asynch/mod.rs:44:9 | 44 | T::send(self, cmd).await | ^^^^^^^^^^^^^^^^^^ await occurs here on type `impl futures::Future<Output = core::result::Result<<Cmd as traits::AtatCmd>::Response, error::Error>>`, which is not `Send` = note: `impl futures::Future<Output = core::result::Result<<Cmd as traits::AtatCmd>::Response, error::Error>>` doesn't implement `core::marker::Send` note: captured value is not `Send` because `&` references cannot be sent unless their referent is `Sync` --> atat/src/asynch/mod.rs:43:44 | 43 | async fn send<Cmd: AtatCmd>(&mut self, cmd: &Cmd) -> Result<Cmd::Response, Error> { | ^^^ has type `&Cmd` which is not `Send`, because `Cmd` is not `Sync` = note: `Cmd` doesn't implement `core::marker::Sync` note: captured value is not `Send` because `&mut` references cannot be sent unless their referent is `Send` --> atat/src/asynch/mod.rs:43:33 | 43 | async fn send<Cmd: AtatCmd>(&mut self, cmd: &Cmd) -> Result<Cmd::Response, Error> { | ^^^^^^^^^ has type `&mut &mut T` which is not `Send`, because `&mut T` is not `Send` = note: `T` doesn't implement `core::marker::Send` = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#future_not_send
T::send(self, cmd).await
}
}
157 changes: 157 additions & 0 deletions atat/src/asynch/simple_client.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,157 @@
use super::AtatClient;
use crate::{helpers::LossyStr, AtatCmd, Config, DigestResult, Digester, Error, Response};
use embassy_time::{with_timeout, Duration, Timer};
use embedded_io_async::{Read, Write};

pub struct SimpleClient<'a, RW: Read + Write, D: Digester> {
rw: RW,
digester: D,
buf: &'a mut [u8],
pos: usize,
config: Config,
cooldown_timer: Option<Timer>,
}

impl<'a, RW: Read + Write, D: Digester> SimpleClient<'a, RW, D> {
pub fn new(rw: RW, digester: D, buf: &'a mut [u8], config: Config) -> Self {
Self {
rw,
digester,
buf,
config,
pos: 0,
cooldown_timer: None,
}
}

async fn send_request(&mut self, len: usize) -> Result<(), Error> {

Check warning on line 27 in atat/src/asynch/simple_client.rs

View workflow job for this annotation

GitHub Actions / clippy

future cannot be sent between threads safely

warning: future cannot be sent between threads safely --> atat/src/asynch/simple_client.rs:27:5 | 27 | async fn send_request(&mut self, len: usize) -> Result<(), Error> { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ future returned by `send_request` is not `Send` | note: future is not `Send` as this value is used across an await --> atat/src/asynch/simple_client.rs:34:36 | 27 | async fn send_request(&mut self, len: usize) -> Result<(), Error> { | --------- has type `&mut asynch::simple_client::SimpleClient<'a, RW, D>` which is not `Send` ... 34 | self.wait_cooldown_timer().await; | ^^^^^ await occurs here, with `&mut self` maybe used later = note: `RW` doesn't implement `core::marker::Send` note: future is not `Send` as this value is used across an await --> atat/src/asynch/simple_client.rs:34:36 | 27 | async fn send_request(&mut self, len: usize) -> Result<(), Error> { | --------- has type `&mut asynch::simple_client::SimpleClient<'a, RW, D>` which is not `Send` ... 34 | self.wait_cooldown_timer().await; | ^^^^^ await occurs here, with `&mut self` maybe used later = note: `D` doesn't implement `core::marker::Send` = note: `impl futures::Future<Output = core::result::Result<(), <RW as embedded_io::ErrorType>::Error>>` doesn't implement `core::marker::Send` = note: `impl futures::Future<Output = core::result::Result<(), <RW as embedded_io::ErrorType>::Error>>` doesn't implement `core::marker::Send` = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#future_not_send
if len < 50 {
debug!("Sending command: {:?}", LossyStr(&self.buf[..len]));
} else {
debug!("Sending command with long payload ({} bytes)", len);
}

self.wait_cooldown_timer().await;

// Write request
with_timeout(self.config.tx_timeout, self.rw.write_all(&self.buf[..len]))
.await
.map_err(|_| Error::Timeout)?
.map_err(|_| Error::Write)?;

with_timeout(self.config.flush_timeout, self.rw.flush())
.await
.map_err(|_| Error::Timeout)?
.map_err(|_| Error::Write)?;

self.start_cooldown_timer();
Ok(())
}

async fn wait_response<'guard>(&'guard mut self) -> Result<Response<256>, Error> {

Check warning on line 51 in atat/src/asynch/simple_client.rs

View workflow job for this annotation

GitHub Actions / clippy

future cannot be sent between threads safely

warning: future cannot be sent between threads safely --> atat/src/asynch/simple_client.rs:51:5 | 51 | async fn wait_response<'guard>(&'guard mut self) -> Result<Response<256>, Error> { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ future returned by `wait_response` is not `Send` | note: future is not `Send` as it awaits another future which is not `Send` --> atat/src/asynch/simple_client.rs:53:19 | 53 | match self.rw.read(&mut self.buf[self.pos..]).await { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ await occurs here on type `impl futures::Future<Output = core::result::Result<usize, <RW as embedded_io::ErrorType>::Error>>`, which is not `Send` = note: `impl futures::Future<Output = core::result::Result<usize, <RW as embedded_io::ErrorType>::Error>>` doesn't implement `core::marker::Send` note: future is not `Send` as this value is used across an await --> atat/src/asynch/simple_client.rs:53:59 | 51 | async fn wait_response<'guard>(&'guard mut self) -> Result<Response<256>, Error> { | ---------------- has type `&mut asynch::simple_client::SimpleClient<'a, RW, D>` which is not `Send` 52 | loop { 53 | match self.rw.read(&mut self.buf[self.pos..]).await { | ^^^^^ await occurs here, with `&'guard mut self` maybe used later = note: `RW` doesn't implement `core::marker::Send` note: future is not `Send` as this value is used across an await --> atat/src/asynch/simple_client.rs:53:59 | 51 | async fn wait_response<'guard>(&'guard mut self) -> Result<Response<256>, Error> { | ---------------- has type `&mut asynch::simple_client::SimpleClient<'a, RW, D>` which is not `Send` 52 | loop { 53 | match self.rw.read(&mut self.buf[self.pos..]).await { | ^^^^^ await occurs here, with `&'guard mut self` maybe used later = note: `D` doesn't implement `core::marker::Send` = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#future_not_send
loop {
match self.rw.read(&mut self.buf[self.pos..]).await {
Ok(n) => {
self.pos += n;
}
_ => return Err(Error::Read),
};

trace!("Buffer contents: '{:?}'", LossyStr(&self.buf[..self.pos]));

while self.pos > 0 {
let (res, swallowed) = match self.digester.digest(&self.buf[..self.pos]) {
(DigestResult::None, swallowed) => {
if swallowed > 0 {
debug!(
"Received echo or whitespace ({}/{}): {:?}",
swallowed,
self.pos,
LossyStr(&self.buf[..swallowed])
);
}
(None, swallowed)
}
(DigestResult::Urc(urc_line), swallowed) => {
warn!("Unable to handle URC! Ignoring: {:?}", LossyStr(urc_line));
(None, swallowed)
}
(DigestResult::Prompt(prompt), swallowed) => {
debug!("Received prompt ({}/{})", swallowed, self.pos);

(Some(Response::Prompt(prompt)), swallowed)
}
(DigestResult::Response(resp), swallowed) => {
match &resp {
Ok(r) => {
if r.is_empty() {
debug!("Received OK ({}/{})", swallowed, self.pos)

Check warning on line 88 in atat/src/asynch/simple_client.rs

View workflow job for this annotation

GitHub Actions / clippy

consider adding a `;` to the last statement for consistent formatting

warning: consider adding a `;` to the last statement for consistent formatting --> atat/src/asynch/simple_client.rs:88:37 | 88 | ... debug!("Received OK ({}/{})", swallowed, self.pos) | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: add a `;` here: `debug!("Received OK ({}/{})", swallowed, self.pos);` | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#semicolon_if_nothing_returned
} else {
debug!(
"Received response ({}/{}): {:?}",
swallowed,
self.pos,
LossyStr(r)
);
}
}
Err(e) => {
warn!(
"Received error response ({}/{}): {:?}",
swallowed, self.pos, e
);
}
}

(Some(resp.into()), swallowed)
}
};

if swallowed == 0 {
break;
}

self.consume(swallowed);

if let Some(resp) = res {
return Ok(resp);
}
}
}
}

fn consume(&mut self, amt: usize) {
self.buf.copy_within(amt..self.pos, 0);
self.pos -= amt;
}

fn start_cooldown_timer(&mut self) {
self.cooldown_timer = Some(Timer::after(self.config.cmd_cooldown));
}

async fn wait_cooldown_timer(&mut self) {

Check warning on line 132 in atat/src/asynch/simple_client.rs

View workflow job for this annotation

GitHub Actions / clippy

future cannot be sent between threads safely

warning: future cannot be sent between threads safely --> atat/src/asynch/simple_client.rs:132:5 | 132 | async fn wait_cooldown_timer(&mut self) { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ future returned by `wait_cooldown_timer` is not `Send` | note: captured value is not `Send` because `&mut` references cannot be sent unless their referent is `Send` --> atat/src/asynch/simple_client.rs:132:34 | 132 | async fn wait_cooldown_timer(&mut self) { | ^^^^^^^^^ has type `&mut asynch::simple_client::SimpleClient<'a, RW, D>` which is not `Send`, because `asynch::simple_client::SimpleClient<'a, RW, D>` is not `Send` = note: `RW` doesn't implement `core::marker::Send` note: captured value is not `Send` because `&mut` references cannot be sent unless their referent is `Send` --> atat/src/asynch/simple_client.rs:132:34 | 132 | async fn wait_cooldown_timer(&mut self) { | ^^^^^^^^^ has type `&mut asynch::simple_client::SimpleClient<'a, RW, D>` which is not `Send`, because `asynch::simple_client::SimpleClient<'a, RW, D>` is not `Send` = note: `D` doesn't implement `core::marker::Send` = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#future_not_send
if let Some(cooldown) = self.cooldown_timer.take() {
cooldown.await

Check warning on line 134 in atat/src/asynch/simple_client.rs

View workflow job for this annotation

GitHub Actions / clippy

consider adding a `;` to the last statement for consistent formatting

warning: consider adding a `;` to the last statement for consistent formatting --> atat/src/asynch/simple_client.rs:134:13 | 134 | cooldown.await | ^^^^^^^^^^^^^^ help: add a `;` here: `cooldown.await;` | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#semicolon_if_nothing_returned
}
}
}

impl<RW: Read + Write, D: Digester> AtatClient for SimpleClient<'_, RW, D> {
async fn send<Cmd: AtatCmd>(&mut self, cmd: &Cmd) -> Result<Cmd::Response, Error> {

Check warning on line 140 in atat/src/asynch/simple_client.rs

View workflow job for this annotation

GitHub Actions / clippy

future cannot be sent between threads safely

warning: future cannot be sent between threads safely --> atat/src/asynch/simple_client.rs:140:5 | 140 | async fn send<Cmd: AtatCmd>(&mut self, cmd: &Cmd) -> Result<Cmd::Response, Error> { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ future returned by `send` is not `Send` | note: future is not `Send` as this value is used across an await --> atat/src/asynch/simple_client.rs:143:32 | 140 | async fn send<Cmd: AtatCmd>(&mut self, cmd: &Cmd) -> Result<Cmd::Response, Error> { | --- has type `&Cmd` which is not `Send` ... 143 | self.send_request(len).await?; | ^^^^^ await occurs here, with `cmd` maybe used later = note: `Cmd` doesn't implement `core::marker::Sync` note: future is not `Send` as this value is used across an await --> atat/src/asynch/simple_client.rs:143:32 | 140 | async fn send<Cmd: AtatCmd>(&mut self, cmd: &Cmd) -> Result<Cmd::Response, Error> { | --------- has type `&mut asynch::simple_client::SimpleClient<'_, RW, D>` which is not `Send` ... 143 | self.send_request(len).await?; | ^^^^^ await occurs here, with `&mut self` maybe used later = note: `RW` doesn't implement `core::marker::Send` note: future is not `Send` as this value is used across an await --> atat/src/asynch/simple_client.rs:143:32 | 140 | async fn send<Cmd: AtatCmd>(&mut self, cmd: &Cmd) -> Result<Cmd::Response, Error> { | --------- has type `&mut asynch::simple_client::SimpleClient<'_, RW, D>` which is not `Send` ... 143 | self.send_request(len).await?; | ^^^^^ await occurs here, with `&mut self` maybe used later = note: `D` doesn't implement `core::marker::Send` = note: `impl futures::Future<Output = core::result::Result<(), <RW as embedded_io::ErrorType>::Error>>` doesn't implement `core::marker::Send` = note: `impl futures::Future<Output = core::result::Result<(), <RW as embedded_io::ErrorType>::Error>>` doesn't implement `core::marker::Send` note: future is not `Send` as it awaits another future which is not `Send` --> atat/src/asynch/simple_client.rs:53:19 | 53 | match self.rw.read(&mut self.buf[self.pos..]).await { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ await occurs here on type `impl futures::Future<Output = core::result::Result<usize, <RW as embedded_io::ErrorType>::Error>>`, which is not `Send` = note: `impl futures::Future<Output = core::result::Result<usize, <RW as embedded_io::ErrorType>::Error>>` doesn't implement `core::marker::Send` = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#future_not_send
let len = cmd.write(&mut self.buf);

Check warning on line 141 in atat/src/asynch/simple_client.rs

View workflow job for this annotation

GitHub Actions / clippy

this expression creates a reference which is immediately dereferenced by the compiler

warning: this expression creates a reference which is immediately dereferenced by the compiler --> atat/src/asynch/simple_client.rs:141:29 | 141 | let len = cmd.write(&mut self.buf); | ^^^^^^^^^^^^^ help: change this to: `self.buf` | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_borrow

self.send_request(len).await?;
if !Cmd::EXPECTS_RESPONSE_CODE {
cmd.parse(Ok(&[]))
} else {
let response = embassy_time::with_timeout(
Duration::from_millis(Cmd::MAX_TIMEOUT_MS.into()),
self.wait_response(),
)
.await
.map_err(|_| Error::Timeout)??;

cmd.parse((&response).into())
}

Check warning on line 155 in atat/src/asynch/simple_client.rs

View workflow job for this annotation

GitHub Actions / clippy

unnecessary boolean `not` operation

warning: unnecessary boolean `not` operation --> atat/src/asynch/simple_client.rs:144:9 | 144 | / if !Cmd::EXPECTS_RESPONSE_CODE { 145 | | cmd.parse(Ok(&[])) 146 | | } else { 147 | | let response = embassy_time::with_timeout( ... | 154 | | cmd.parse((&response).into()) 155 | | } | |_________^ | = help: remove the `!` and swap the blocks of the `if`/`else` = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#if_not_else
}
}
Loading

0 comments on commit 6a5902e

Please sign in to comment.