diff --git a/atat/src/buffers.rs b/atat/src/buffers.rs deleted file mode 100644 index 4e19ef56..00000000 --- a/atat/src/buffers.rs +++ /dev/null @@ -1,78 +0,0 @@ -use embedded_io::Write; - -use crate::{ - response_channel::ResponseChannel, urc_channel::UrcChannel, AtatUrc, Config, Digester, Ingress, -}; - -pub struct Buffers< - Urc: AtatUrc, - const INGRESS_BUF_SIZE: usize, - const URC_CAPACITY: usize, - const URC_SUBSCRIBERS: usize, -> { - res_channel: ResponseChannel, - /// The URC pub/sub channel - pub urc_channel: UrcChannel, -} - -impl< - Urc: AtatUrc, - const INGRESS_BUF_SIZE: usize, - const URC_CAPACITY: usize, - const URC_SUBSCRIBERS: usize, - > Buffers -{ - pub const fn new() -> Self { - Self { - res_channel: ResponseChannel::new(), - urc_channel: UrcChannel::new(), - } - } -} - -impl< - Urc: AtatUrc, - const INGRESS_BUF_SIZE: usize, - const URC_CAPACITY: usize, - const URC_SUBSCRIBERS: usize, - > Buffers -{ - #[cfg(feature = "async")] - pub fn split( - &self, - writer: W, - digester: D, - config: Config, - ) -> ( - Ingress, - crate::asynch::Client, - ) { - ( - Ingress::new( - digester, - self.res_channel.publisher().unwrap(), - self.urc_channel.publisher(), - ), - crate::asynch::Client::new(writer, &self.res_channel, config), - ) - } - - pub fn split_blocking( - &self, - writer: W, - digester: D, - config: Config, - ) -> ( - Ingress, - crate::blocking::Client, - ) { - ( - Ingress::new( - digester, - self.res_channel.publisher().unwrap(), - self.urc_channel.publisher(), - ), - crate::blocking::Client::new(writer, &self.res_channel, config), - ) - } -} diff --git a/atat/src/lib.rs b/atat/src/lib.rs index caec3ef7..09a7df3f 100644 --- a/atat/src/lib.rs +++ b/atat/src/lib.rs @@ -222,7 +222,6 @@ // This mod MUST go first, so that the others see its macros. pub(crate) mod fmt; -mod buffers; mod config; pub mod digest; mod error; @@ -261,7 +260,6 @@ pub use serde_at; #[cfg(feature = "derive")] pub use heapless; -pub use buffers::Buffers; pub use config::Config; pub use digest::{AtDigester, AtDigester as DefaultDigester, DigestResult, Digester, Parser}; pub use error::{CmeError, CmsError, ConnectionError, Error, InternalError}; diff --git a/atat_derive/src/helpers.rs b/atat_derive/src/helpers.rs index cc018462..b5217608 100644 --- a/atat_derive/src/helpers.rs +++ b/atat_derive/src/helpers.rs @@ -52,7 +52,7 @@ pub fn add_type_parameter_bound( let where_type = syn::PredicateType { bounded_ty: parse_quote!(#ident), colon_token: ::default(), - bounds: vec![trait_bound].iter().cloned().collect(), + bounds: [trait_bound].iter().cloned().collect(), lifetimes: None, }; generics diff --git a/examples/src/bin/embassy.rs b/examples/src/bin/embassy.rs index 668154a3..3f19117d 100644 --- a/examples/src/bin/embassy.rs +++ b/examples/src/bin/embassy.rs @@ -3,7 +3,10 @@ #![feature(type_alias_impl_trait)] #![allow(incomplete_features)] -use atat::{asynch::AtatClient, AtatIngress, Buffers, DefaultDigester, Ingress}; +use atat::{ + asynch::{AtatClient, Client}, + AtatIngress, DefaultDigester, Ingress, ResponseChannel, UrcChannel, +}; use atat_examples::common; use embassy_executor::Spawner; use embassy_executor::_export::StaticCell; @@ -47,14 +50,14 @@ async fn main(spawner: Spawner) { ); let (reader, writer) = uart.split(); - static BUFFERS: Buffers = - Buffers::::new(); - - let (ingress, mut client) = BUFFERS.split( - writer, + static RES_CHANNEL: ResponseChannel = ResponseChannel::new(); + static URC_CHANNEL: UrcChannel = UrcChannel::new(); + let ingress = Ingress::new( DefaultDigester::::default(), - atat::Config::default(), + RES_CHANNEL.publisher(), + URC_CHANNEL.publisher(), ); + let mut client = Client::new(writer, RES_CHANNEL.subscriber(), atat::Config::default()); spawner.spawn(ingress_task(ingress, reader)).unwrap(); diff --git a/examples/src/bin/std-tokio.rs b/examples/src/bin/std-tokio.rs index c7187be2..a1911120 100644 --- a/examples/src/bin/std-tokio.rs +++ b/examples/src/bin/std-tokio.rs @@ -2,10 +2,12 @@ #![allow(incomplete_features)] use atat_examples::common; -use std::process::exit; - -use atat::{asynch::AtatClient, AtatIngress, Buffers, Config, DefaultDigester, Ingress}; +use atat::{ + asynch::{AtatClient, Client}, + AtatIngress, Config, DefaultDigester, Ingress, ResponseChannel, UrcChannel, +}; use embedded_io_adapters::tokio_1::FromTokio; +use std::process::exit; use tokio_serial::SerialStream; const INGRESS_BUF_SIZE: usize = 1024; @@ -16,16 +18,16 @@ const URC_SUBSCRIBERS: usize = 3; async fn main() -> ! { env_logger::init(); - static BUFFERS: Buffers = - Buffers::::new(); - let (reader, writer) = SerialStream::pair().expect("Failed to create serial pair"); - let (ingress, mut client) = BUFFERS.split( - FromTokio::new(writer), + static RES_CHANNEL: ResponseChannel = ResponseChannel::new(); + static URC_CHANNEL: UrcChannel = UrcChannel::new(); + let ingress = Ingress::new( DefaultDigester::::default(), - Config::default(), + RES_CHANNEL.publisher().unwrap(), + URC_CHANNEL.publisher(), ); + let mut client = Client::new(FromTokio::new(writer), &RES_CHANNEL, Config::default()); tokio::spawn(ingress_task(ingress, FromTokio::new(reader))); diff --git a/serde_at/src/de/mod.rs b/serde_at/src/de/mod.rs index 82d21ae6..0658bf38 100644 --- a/serde_at/src/de/mod.rs +++ b/serde_at/src/de/mod.rs @@ -176,16 +176,14 @@ impl<'a> Deserializer<'a> { if self.is_trailing_parsing { self.index = self.slice.len(); return Ok(&self.slice[start..]); - } else { - if let Some(c) = self.peek() { - if (c as char).is_alphanumeric() || (c as char).is_whitespace() { - self.eat_char(); - } else { - return Err(Error::EofWhileParsingString); - } + } else if let Some(c) = self.peek() { + if (c as char).is_alphanumeric() || (c as char).is_whitespace() { + self.eat_char(); } else { - return Ok(&self.slice[start..self.index]); + return Err(Error::EofWhileParsingString); } + } else { + return Ok(&self.slice[start..self.index]); } } }