Skip to content

Commit

Permalink
Remove Buffers type (FactbirdHQ#193)
Browse files Browse the repository at this point in the history
* Remove Buffers type

* Fix clippy warnings

* Fix CI

* Fix std-tokio example build errors
  • Loading branch information
rmja authored Dec 19, 2023
1 parent 1a9cee6 commit 94eb974
Show file tree
Hide file tree
Showing 6 changed files with 28 additions and 105 deletions.
78 changes: 0 additions & 78 deletions atat/src/buffers.rs

This file was deleted.

2 changes: 0 additions & 2 deletions atat/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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};
Expand Down
2 changes: 1 addition & 1 deletion atat_derive/src/helpers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ pub fn add_type_parameter_bound(
let where_type = syn::PredicateType {
bounded_ty: parse_quote!(#ident),
colon_token: <syn::Token![:]>::default(),
bounds: vec![trait_bound].iter().cloned().collect(),
bounds: [trait_bound].iter().cloned().collect(),
lifetimes: None,
};
generics
Expand Down
17 changes: 10 additions & 7 deletions examples/src/bin/embassy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -47,14 +50,14 @@ async fn main(spawner: Spawner) {
);
let (reader, writer) = uart.split();

static BUFFERS: Buffers<common::Urc, INGRESS_BUF_SIZE, URC_CAPACITY, URC_SUBSCRIBERS> =
Buffers::<common::Urc, INGRESS_BUF_SIZE, URC_CAPACITY, URC_SUBSCRIBERS>::new();

let (ingress, mut client) = BUFFERS.split(
writer,
static RES_CHANNEL: ResponseChannel<INGRESS_BUF_SIZE> = ResponseChannel::new();
static URC_CHANNEL: UrcChannel<Urc, URC_CAPACITY, URC_SUBSCRIBERS> = UrcChannel::new();
let ingress = Ingress::new(
DefaultDigester::<common::Urc>::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();

Expand Down
20 changes: 11 additions & 9 deletions examples/src/bin/std-tokio.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -16,16 +18,16 @@ const URC_SUBSCRIBERS: usize = 3;
async fn main() -> ! {
env_logger::init();

static BUFFERS: Buffers<common::Urc, INGRESS_BUF_SIZE, URC_CAPACITY, URC_SUBSCRIBERS> =
Buffers::<common::Urc, INGRESS_BUF_SIZE, URC_CAPACITY, URC_SUBSCRIBERS>::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<INGRESS_BUF_SIZE> = ResponseChannel::new();
static URC_CHANNEL: UrcChannel<common::Urc, URC_CAPACITY, URC_SUBSCRIBERS> = UrcChannel::new();
let ingress = Ingress::new(
DefaultDigester::<common::Urc>::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)));

Expand Down
14 changes: 6 additions & 8 deletions serde_at/src/de/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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]);
}
}
}
Expand Down

0 comments on commit 94eb974

Please sign in to comment.