Skip to content

Commit

Permalink
Rename PacketWriter to PacketTransport
Browse files Browse the repository at this point in the history
  • Loading branch information
Dima Dorezyuk committed Dec 8, 2023
1 parent b34c99a commit a8261f8
Show file tree
Hide file tree
Showing 8 changed files with 22 additions and 35 deletions.
12 changes: 0 additions & 12 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion zvt/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
4 changes: 2 additions & 2 deletions zvt/src/bin/feig_update/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)]
Expand Down Expand Up @@ -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,
Expand Down
4 changes: 2 additions & 2 deletions zvt/src/bin/status/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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,
Expand Down
4 changes: 2 additions & 2 deletions zvt/src/feig/sequences.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use crate::logging::PacketWriter;
use crate::io::PacketTransport;
use crate::sequences::Sequence;
use crate::{packets, ZvtEnum};
use anyhow::Result;
Expand Down Expand Up @@ -95,7 +95,7 @@ impl WriteFile {
path: PathBuf,
password: usize,
adpu_size: u32,
src: &mut PacketWriter<Source>,
src: &mut PacketTransport<Source>,
) -> Pin<Box<impl Stream<Item = Result<WriteFileResponse>> + '_>>
where
Source: AsyncReadExt + AsyncWriteExt + Unpin + Send,
Expand Down
8 changes: 4 additions & 4 deletions zvt/src/logging.rs → zvt/src/io.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@ pub enum Ack {
Ack(packets::Ack),
}

pub struct PacketWriter<Source> {
pub struct PacketTransport<Source> {
pub source: Source,
}

impl<S> PacketWriter<S>
impl<S> PacketTransport<S>
where
S: AsyncReadExt + Unpin + Send,
{
Expand Down Expand Up @@ -46,7 +46,7 @@ where
}
}

impl<S> PacketWriter<S>
impl<S> PacketTransport<S>
where
S: AsyncWriteExt + Unpin + Send,
{
Expand All @@ -65,7 +65,7 @@ where
}
}

impl<S> PacketWriter<S>
impl<S> PacketTransport<S>
where
S: AsyncWriteExt + AsyncReadExt + Unpin + Send,
{
Expand Down
2 changes: 1 addition & 1 deletion zvt/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
pub mod constants;
pub mod feig;
pub mod logging;
pub mod io;
pub mod packets;
pub mod sequences;

Expand Down
22 changes: 11 additions & 11 deletions zvt/src/sequences.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use crate::logging::PacketWriter;
use crate::io::PacketTransport;
use crate::packets;
use crate::{encoding, ZvtEnum, ZvtParser, ZvtSerializer};
use anyhow::Result;
Expand Down Expand Up @@ -32,7 +32,7 @@ where

fn into_stream<'a, Source>(
input: &'a Self::Input,
src: &'a mut PacketWriter<Source>,
src: &'a mut PacketTransport<Source>,
) -> Pin<Box<dyn futures::Stream<Item = Result<Self::Output>> + Send + 'a>>
where
Source: AsyncReadExt + AsyncWriteExt + Unpin + Send,
Expand Down Expand Up @@ -89,7 +89,7 @@ impl Sequence for ReadCard {

fn into_stream<'a, Source>(
input: &'a Self::Input,
src: &'a mut PacketWriter<Source>,
src: &'a mut PacketTransport<Source>,
) -> Pin<Box<dyn futures::Stream<Item = Result<Self::Output>> + Send + 'a>>
where
Source: AsyncReadExt + AsyncWriteExt + Unpin + Send,
Expand Down Expand Up @@ -142,7 +142,7 @@ impl Sequence for Initialization {

fn into_stream<'a, Source>(
input: &'a Self::Input,
src: &'a mut PacketWriter<Source>,
src: &'a mut PacketTransport<Source>,
) -> Pin<Box<dyn Stream<Item = Result<Self::Output>> + Send + 'a>>
where
Source: AsyncReadExt + AsyncWriteExt + Unpin + Send,
Expand Down Expand Up @@ -247,7 +247,7 @@ impl Sequence for Diagnosis {

fn into_stream<'a, Source>(
input: &'a Self::Input,
src: &'a mut PacketWriter<Source>,
src: &'a mut PacketTransport<Source>,
) -> Pin<Box<dyn Stream<Item = Result<Self::Output>> + Send + 'a>>
where
Source: AsyncReadExt + AsyncWriteExt + Unpin + Send,
Expand Down Expand Up @@ -311,7 +311,7 @@ impl Sequence for EndOfDay {

fn into_stream<'a, Source>(
input: &'a Self::Input,
src: &'a mut PacketWriter<Source>,
src: &'a mut PacketTransport<Source>,
) -> Pin<Box<dyn Stream<Item = Result<Self::Output>> + Send + 'a>>
where
Source: AsyncReadExt + AsyncWriteExt + Unpin + Send,
Expand Down Expand Up @@ -376,7 +376,7 @@ impl Sequence for Reservation {

fn into_stream<'a, Source>(
input: &'a Self::Input,
src: &'a mut PacketWriter<Source>,
src: &'a mut PacketTransport<Source>,
) -> Pin<Box<dyn Stream<Item = Result<Self::Output>> + Send + 'a>>
where
Source: AsyncReadExt + AsyncWriteExt + Unpin + Send,
Expand Down Expand Up @@ -445,7 +445,7 @@ impl Sequence for PartialReversal {

fn into_stream<'a, Source>(
input: &'a Self::Input,
src: &'a mut PacketWriter<Source>,
src: &'a mut PacketTransport<Source>,
) -> Pin<Box<dyn Stream<Item = Result<Self::Output>> + Send + 'a>>
where
Source: AsyncReadExt + AsyncWriteExt + Unpin + Send,
Expand Down Expand Up @@ -483,7 +483,7 @@ impl Sequence for PreAuthReversal {

fn into_stream<'a, Source>(
input: &'a Self::Input,
src: &'a mut PacketWriter<Source>,
src: &'a mut PacketTransport<Source>,
) -> Pin<Box<dyn Stream<Item = Result<Self::Output>> + Send + 'a>>
where
Source: AsyncReadExt + AsyncWriteExt + Unpin + Send,
Expand Down Expand Up @@ -532,7 +532,7 @@ impl Sequence for PrintSystemConfiguration {

fn into_stream<'a, Source>(
input: &'a Self::Input,
src: &'a mut PacketWriter<Source>,
src: &'a mut PacketTransport<Source>,
) -> Pin<Box<dyn Stream<Item = Result<Self::Output>> + Send + 'a>>
where
Source: AsyncReadExt + AsyncWriteExt + Unpin + Send,
Expand Down Expand Up @@ -601,7 +601,7 @@ impl Sequence for StatusEnquiry {

fn into_stream<'a, Source>(
input: &'a Self::Input,
src: &'a mut PacketWriter<Source>,
src: &'a mut PacketTransport<Source>,
) -> Pin<Box<dyn Stream<Item = Result<Self::Output>> + Send + 'a>>
where
Source: AsyncReadExt + AsyncWriteExt + Unpin + Send,
Expand Down

0 comments on commit a8261f8

Please sign in to comment.