From a8261f8a474f6e9625c5a2b4dec1c4bd6a13cec0 Mon Sep 17 00:00:00 2001 From: Dima Dorezyuk Date: Fri, 8 Dec 2023 14:31:18 +0100 Subject: [PATCH] Rename PacketWriter to PacketTransport --- Cargo.lock | 12 ------------ zvt/Cargo.toml | 1 - zvt/src/bin/feig_update/main.rs | 4 ++-- zvt/src/bin/status/main.rs | 4 ++-- zvt/src/feig/sequences.rs | 4 ++-- zvt/src/{logging.rs => io.rs} | 8 ++++---- zvt/src/lib.rs | 2 +- zvt/src/sequences.rs | 22 +++++++++++----------- 8 files changed, 22 insertions(+), 35 deletions(-) rename zvt/src/{logging.rs => io.rs} (95%) diff --git a/Cargo.lock b/Cargo.lock index c34c492..6acf5ec 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -117,17 +117,6 @@ dependencies = [ "syn", ] -[[package]] -name = "async-trait" -version = "0.1.74" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a66537f1bb974b254c98ed142ff995236e81b9d0fe4db0575f46612cb15eb0f9" -dependencies = [ - "proc-macro2", - "quote", - "syn", -] - [[package]] name = "autocfg" version = "1.1.0" @@ -929,7 +918,6 @@ version = "0.1.1" dependencies = [ "anyhow", "async-stream", - "async-trait", "chrono", "clap", "env_logger", diff --git a/zvt/Cargo.toml b/zvt/Cargo.toml index f30a975..5fd85cb 100644 --- a/zvt/Cargo.toml +++ b/zvt/Cargo.toml @@ -27,4 +27,3 @@ async-stream = "0.3.5" serde = { version = "1.0.185", features = ["derive"] } serde_json = "1.0.105" futures = "0.3.28" -async-trait = "0.1.74" diff --git a/zvt/src/bin/feig_update/main.rs b/zvt/src/bin/feig_update/main.rs index d84453e..cfeb119 100644 --- a/zvt/src/bin/feig_update/main.rs +++ b/zvt/src/bin/feig_update/main.rs @@ -5,7 +5,7 @@ use std::fs::read_to_string; use std::path::PathBuf; use tokio::net::TcpStream; use tokio_stream::StreamExt; -use zvt::{feig, logging, packets, sequences, sequences::Sequence}; +use zvt::{feig, io, packets, sequences, sequences::Sequence}; /// Updates a feig terminal. #[derive(Parser)] @@ -54,7 +54,7 @@ async fn main() -> Result<()> { // Connect to the payment terminal. let source = TcpStream::connect(&args.ip_address).await?; - let mut socket = logging::PacketWriter { source }; + let mut socket = io::PacketTransport { source }; const MAX_LEN_ADPU: u16 = 1u16 << 15; let registration = packets::Registration { password: args.password, diff --git a/zvt/src/bin/status/main.rs b/zvt/src/bin/status/main.rs index 1165be7..926dab0 100644 --- a/zvt/src/bin/status/main.rs +++ b/zvt/src/bin/status/main.rs @@ -4,7 +4,7 @@ use log::info; use std::io::Write; use tokio::net::TcpStream; use tokio_stream::StreamExt; -use zvt::{logging, packets, sequences, sequences::Sequence}; +use zvt::{io, packets, sequences, sequences::Sequence}; #[derive(Parser, Debug)] struct Args { @@ -58,7 +58,7 @@ async fn main() -> std::io::Result<()> { info!("Using the args {:?}", args); let source = TcpStream::connect(args.ip).await?; - let mut socket = logging::PacketWriter { source }; + let mut socket = io::PacketTransport { source }; let request = packets::Registration { password: args.password, diff --git a/zvt/src/feig/sequences.rs b/zvt/src/feig/sequences.rs index 1c9580c..08959a6 100644 --- a/zvt/src/feig/sequences.rs +++ b/zvt/src/feig/sequences.rs @@ -1,4 +1,4 @@ -use crate::logging::PacketWriter; +use crate::io::PacketTransport; use crate::sequences::Sequence; use crate::{packets, ZvtEnum}; use anyhow::Result; @@ -95,7 +95,7 @@ impl WriteFile { path: PathBuf, password: usize, adpu_size: u32, - src: &mut PacketWriter, + src: &mut PacketTransport, ) -> Pin> + '_>> where Source: AsyncReadExt + AsyncWriteExt + Unpin + Send, diff --git a/zvt/src/logging.rs b/zvt/src/io.rs similarity index 95% rename from zvt/src/logging.rs rename to zvt/src/io.rs index 8275bdb..215f532 100644 --- a/zvt/src/logging.rs +++ b/zvt/src/io.rs @@ -11,11 +11,11 @@ pub enum Ack { Ack(packets::Ack), } -pub struct PacketWriter { +pub struct PacketTransport { pub source: Source, } -impl PacketWriter +impl PacketTransport where S: AsyncReadExt + Unpin + Send, { @@ -46,7 +46,7 @@ where } } -impl PacketWriter +impl PacketTransport where S: AsyncWriteExt + Unpin + Send, { @@ -65,7 +65,7 @@ where } } -impl PacketWriter +impl PacketTransport where S: AsyncWriteExt + AsyncReadExt + Unpin + Send, { diff --git a/zvt/src/lib.rs b/zvt/src/lib.rs index 17eb6f7..7b50638 100644 --- a/zvt/src/lib.rs +++ b/zvt/src/lib.rs @@ -1,6 +1,6 @@ pub mod constants; pub mod feig; -pub mod logging; +pub mod io; pub mod packets; pub mod sequences; diff --git a/zvt/src/sequences.rs b/zvt/src/sequences.rs index f9a8217..a33fd27 100644 --- a/zvt/src/sequences.rs +++ b/zvt/src/sequences.rs @@ -1,4 +1,4 @@ -use crate::logging::PacketWriter; +use crate::io::PacketTransport; use crate::packets; use crate::{encoding, ZvtEnum, ZvtParser, ZvtSerializer}; use anyhow::Result; @@ -32,7 +32,7 @@ where fn into_stream<'a, Source>( input: &'a Self::Input, - src: &'a mut PacketWriter, + src: &'a mut PacketTransport, ) -> Pin> + Send + 'a>> where Source: AsyncReadExt + AsyncWriteExt + Unpin + Send, @@ -89,7 +89,7 @@ impl Sequence for ReadCard { fn into_stream<'a, Source>( input: &'a Self::Input, - src: &'a mut PacketWriter, + src: &'a mut PacketTransport, ) -> Pin> + Send + 'a>> where Source: AsyncReadExt + AsyncWriteExt + Unpin + Send, @@ -142,7 +142,7 @@ impl Sequence for Initialization { fn into_stream<'a, Source>( input: &'a Self::Input, - src: &'a mut PacketWriter, + src: &'a mut PacketTransport, ) -> Pin> + Send + 'a>> where Source: AsyncReadExt + AsyncWriteExt + Unpin + Send, @@ -247,7 +247,7 @@ impl Sequence for Diagnosis { fn into_stream<'a, Source>( input: &'a Self::Input, - src: &'a mut PacketWriter, + src: &'a mut PacketTransport, ) -> Pin> + Send + 'a>> where Source: AsyncReadExt + AsyncWriteExt + Unpin + Send, @@ -311,7 +311,7 @@ impl Sequence for EndOfDay { fn into_stream<'a, Source>( input: &'a Self::Input, - src: &'a mut PacketWriter, + src: &'a mut PacketTransport, ) -> Pin> + Send + 'a>> where Source: AsyncReadExt + AsyncWriteExt + Unpin + Send, @@ -376,7 +376,7 @@ impl Sequence for Reservation { fn into_stream<'a, Source>( input: &'a Self::Input, - src: &'a mut PacketWriter, + src: &'a mut PacketTransport, ) -> Pin> + Send + 'a>> where Source: AsyncReadExt + AsyncWriteExt + Unpin + Send, @@ -445,7 +445,7 @@ impl Sequence for PartialReversal { fn into_stream<'a, Source>( input: &'a Self::Input, - src: &'a mut PacketWriter, + src: &'a mut PacketTransport, ) -> Pin> + Send + 'a>> where Source: AsyncReadExt + AsyncWriteExt + Unpin + Send, @@ -483,7 +483,7 @@ impl Sequence for PreAuthReversal { fn into_stream<'a, Source>( input: &'a Self::Input, - src: &'a mut PacketWriter, + src: &'a mut PacketTransport, ) -> Pin> + Send + 'a>> where Source: AsyncReadExt + AsyncWriteExt + Unpin + Send, @@ -532,7 +532,7 @@ impl Sequence for PrintSystemConfiguration { fn into_stream<'a, Source>( input: &'a Self::Input, - src: &'a mut PacketWriter, + src: &'a mut PacketTransport, ) -> Pin> + Send + 'a>> where Source: AsyncReadExt + AsyncWriteExt + Unpin + Send, @@ -601,7 +601,7 @@ impl Sequence for StatusEnquiry { fn into_stream<'a, Source>( input: &'a Self::Input, - src: &'a mut PacketWriter, + src: &'a mut PacketTransport, ) -> Pin> + Send + 'a>> where Source: AsyncReadExt + AsyncWriteExt + Unpin + Send,