From dd7eb63afbbb0e1cd2fac368f2441a931ff3defe Mon Sep 17 00:00:00 2001 From: Bilal Elmoussaoui Date: Thu, 13 Feb 2025 12:20:35 +0100 Subject: [PATCH] turn into a proper library with a separate example the example can be built with cargo run --example example --- Cargo.lock | 26 +++++++++++----------- Cargo.toml | 6 ++++- src/{lib_ykoath2 => }/constants.rs | 0 src/{main.rs => example.rs} | 2 -- src/{lib_ykoath2/mod.rs => lib.rs} | 0 src/{lib_ykoath2 => }/oath_credential.rs | 2 +- src/{lib_ykoath2 => }/oath_credentialid.rs | 2 +- src/{lib_ykoath2 => }/transaction.rs | 2 +- 8 files changed, 21 insertions(+), 19 deletions(-) rename src/{lib_ykoath2 => }/constants.rs (100%) rename src/{main.rs => example.rs} (99%) rename src/{lib_ykoath2/mod.rs => lib.rs} (100%) rename src/{lib_ykoath2 => }/oath_credential.rs (96%) rename src/{lib_ykoath2 => }/oath_credentialid.rs (97%) rename src/{lib_ykoath2 => }/transaction.rs (98%) diff --git a/Cargo.lock b/Cargo.lock index 3e80e4c..34a9edc 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -121,19 +121,7 @@ dependencies = [ ] [[package]] -name = "libc" -version = "0.2.169" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b5aba8db14291edd000dfcc4d620c7ebfb122c613afb886ca8803fa4e128a20a" - -[[package]] -name = "memchr" -version = "2.7.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "78ca9ab1a0babb1e7d5695e3530886289c18cf2f87ec19a575a0abdce112e3a3" - -[[package]] -name = "oath-rs-experiments" +name = "lib_ykoath2" version = "0.1.0" dependencies = [ "apdu-core", @@ -150,6 +138,18 @@ dependencies = [ "strum_macros", ] +[[package]] +name = "libc" +version = "0.2.169" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b5aba8db14291edd000dfcc4d620c7ebfb122c613afb886ca8803fa4e128a20a" + +[[package]] +name = "memchr" +version = "2.7.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "78ca9ab1a0babb1e7d5695e3530886289c18cf2f87ec19a575a0abdce112e3a3" + [[package]] name = "ouroboros" version = "0.18.5" diff --git a/Cargo.toml b/Cargo.toml index 5d804f8..5fe1738 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -13,9 +13,13 @@ strum = { version = "0.27.0", features = [ ] } strum_macros = "0.27.0" [package] -name = "oath-rs-experiments" +name = "lib_ykoath2" version = "0.1.0" edition = "2021" authors = ["Grimmauld "] description = "experiments with smartcards" license-file = "LICENSE" + +[[example]] +name = "example" +path = "./src/example.rs" \ No newline at end of file diff --git a/src/lib_ykoath2/constants.rs b/src/constants.rs similarity index 100% rename from src/lib_ykoath2/constants.rs rename to src/constants.rs diff --git a/src/main.rs b/src/example.rs similarity index 99% rename from src/main.rs rename to src/example.rs index c6f19b9..1931d1c 100644 --- a/src/main.rs +++ b/src/example.rs @@ -1,7 +1,5 @@ // SPDX-License-Identifier: BSD-3-Clause -mod lib_ykoath2; - use core::time; use lib_ykoath2::OathSession; use pcsc; diff --git a/src/lib_ykoath2/mod.rs b/src/lib.rs similarity index 100% rename from src/lib_ykoath2/mod.rs rename to src/lib.rs diff --git a/src/lib_ykoath2/oath_credential.rs b/src/oath_credential.rs similarity index 96% rename from src/lib_ykoath2/oath_credential.rs rename to src/oath_credential.rs index 6cc0140..6344520 100644 --- a/src/lib_ykoath2/oath_credential.rs +++ b/src/oath_credential.rs @@ -1,7 +1,7 @@ use std::cmp::Ordering; use std::hash::{Hash, Hasher}; -use crate::lib_ykoath2::CredentialIDData; +use crate::CredentialIDData; #[derive(Debug, Clone)] pub struct OathCredential { diff --git a/src/lib_ykoath2/oath_credentialid.rs b/src/oath_credentialid.rs similarity index 97% rename from src/lib_ykoath2/oath_credentialid.rs rename to src/oath_credentialid.rs index 08191a1..63a7e56 100644 --- a/src/lib_ykoath2/oath_credentialid.rs +++ b/src/oath_credentialid.rs @@ -2,7 +2,7 @@ use regex::Regex; use std::fmt::Display; -use crate::lib_ykoath2::{OathType, Tag, DEFAULT_PERIOD}; +use crate::{OathType, Tag, DEFAULT_PERIOD}; #[derive(Debug, Eq, PartialEq, Clone)] pub struct CredentialIDData { diff --git a/src/lib_ykoath2/transaction.rs b/src/transaction.rs similarity index 98% rename from src/lib_ykoath2/transaction.rs rename to src/transaction.rs index a7817b1..002b07f 100644 --- a/src/lib_ykoath2/transaction.rs +++ b/src/transaction.rs @@ -9,7 +9,7 @@ use pcsc::{Card, Transaction}; use std::ffi::CString; -use crate::lib_ykoath2::{ErrorResponse, Instruction, SuccessResponse, Tag}; +use crate::{ErrorResponse, Instruction, SuccessResponse, Tag}; #[derive(PartialEq, Eq, Debug)] pub enum FormattableErrorResponse {