Giter Site home page Giter Site logo

apdu-rs's Introduction

๐Ÿฆ€ apdu-rs

Rust

Rust library to compose or parse APDU commands and responses.

๐Ÿ— Crates

This repository is made of these crates separately:

apdu

crates.io docs

apdu-core

crates.io docs

apdu-derive

crates.io docs

๐Ÿ“ฆ Getting Started

Add to your Cargo.toml as a dependency as follows:

[dependencies]
apdu = "0.3"

๐Ÿ›  Longer payloads support

This library supports longer payloads of APDU commands and responses. If you want to use these, turn longer_payloads feature on:

apdu-core = { version = "0.3", features = ["longer_payloads"] }

๐Ÿ›  no_std support

apdu-core crate does support no_std environments (but it requires alloc yet). If you are using this crate in no_std, turn std feature off by disabling default features:

[dependencies]
apdu-core = { version = "0.3", default-features = false }

๐Ÿ“„ Documentation

See docs.rs.

apdu-rs's People

Contributors

adryd325 avatar mstrodl avatar siketyan avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

apdu-rs's Issues

Missing `Debug` impls on public types

I noticed that apdu-rs does not implement Debug for all public types. After adding #![warn(missing_debug_implementations)] to all crates, the compiler tells me that they are missing for the following types:

  • apdu_core::Command
  • apdu::command::ReadBinaryCommand
  • apdu::command::SelectFileCommand
  • apdu::command::VerifyCommand

This makes debugging quite a bit harder than it needs to be. Is this by design, or simply an oversight? If the latter, would you welcome a pull request enabling the missing_debug_implementations warning and adding Debug impls for those types?

`no_std` support without `alloc`?

I found this crate by chance yesterday. I thought I could use it for a Rust-embedded demo with some NFC tags I have (but I don't have the right type of tags).

That said, I tried compiling the crate as a test. The README.md says apdu-core supports no-std environments. But when I try to compile it, I an error saying the crate needs alloc, which leads to a bunch of other errors:

$ cargo +nightly build -p apdu-core --target=msp430-none-elf --no-default-features -Zbuild-std=core
   Compiling apdu-core v0.2.1 (C:\msys64\home\William\Projects\rust-embedded\apdu-rs\apdu-core)
error[E0463]: can't find crate for `alloc`
 --> apdu-core\src\lib.rs:5:1
  |
5 | extern crate alloc;
  | ^^^^^^^^^^^^^^^^^^^ can't find crate

error: cannot determine resolution for the macro `vec`
  --> apdu-core\src\command.rs:80:35
   |
80 |         let mut buffer: Vec<u8> = vec![cla, ins, p1, p2];
   |                                   ^^^
   |
   = note: import resolution is stuck, try simplifying macro imports

error[E0412]: cannot find type `Vec` in this scope
 --> apdu-core\src\response.rs:6:18
  |
6 |     pub payload: Vec<u8>,
  |                  ^^^ not found in this scope

error[E0412]: cannot find type `Vec` in this scope
  --> apdu-core\src\response.rs:22:11
   |
22 | impl From<Vec<u8>> for Response {
   |           ^^^ not found in this scope

error[E0412]: cannot find type `Vec` in this scope
  --> apdu-core\src\response.rs:23:24
   |
23 |     fn from(mut bytes: Vec<u8>) -> Self {
   |                        ^^^ not found in this scope

error[E0412]: cannot find type `Vec` in this scope
  --> apdu-core\src\response.rs:37:32
   |
37 | impl From<Response> for Result<Vec<u8>, Error> {
   |                                ^^^ not found in this scope

error[E0282]: type annotations needed
  --> apdu-core\src\command.rs:24:22
   |
24 |             payload: None,
   |                      ^^^^ cannot infer type of the type parameter `T` declared on the enum `Option`
   |
help: consider specifying the generic argument
   |
24 |             payload: None::<T>,
   |                          +++++

error[E0282]: type annotations needed
  --> apdu-core\src\command.rs:37:22
   |
37 |             payload: None,
   |                      ^^^^ cannot infer type of the type parameter `T` declared on the enum `Option`
   |
help: consider specifying the generic argument
   |
37 |             payload: None::<T>,
   |                          +++++

error[E0283]: type annotations needed
 --> apdu-core\src\response.rs:6:5
  |
4 | #[derive(Debug, Default)]
  |                 ------- in this derive macro expansion
5 | pub struct Response {
6 |     pub payload: Vec<u8>,
  |     ^^^^^^^^^^^^^^^^^^^^ cannot infer type
  |
  = note: cannot satisfy `_: Default`
  = note: this error originates in the derive macro `Default` (in Nightly builds, run with -Z macro-backtrace for more info)

Some errors have detailed explanations: E0282, E0283, E0412, E0463.
For more information about an error, try `rustc --explain E0282`.
error: could not compile `apdu-core` due to 9 previous errors

msp430-none-elf is just an example here; it doesn't support alloc and probably never will. Is it possible to make apdu-core support fixed buffer sizes to be usable without alloc?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.