Skip to content

Commit

Permalink
feat: Support no_std environment
Browse files Browse the repository at this point in the history
  • Loading branch information
siketyan committed Sep 24, 2022
1 parent 9477be4 commit 62732d7
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 2 deletions.
4 changes: 4 additions & 0 deletions apdu-core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,7 @@ authors = [
]

[dependencies]

[features]
std = []
default = ["std"]
3 changes: 3 additions & 0 deletions apdu-core/src/command.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
use alloc::vec;
use alloc::vec::Vec;

/// An APDU command to be transmitted
pub struct Command {
pub cla: u8,
Expand Down
5 changes: 3 additions & 2 deletions apdu-core/src/error.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use std::fmt::{Display, Formatter};
use core::fmt::{Display, Formatter};

use crate::Response;

Expand All @@ -9,7 +9,7 @@ pub struct Error {
}

impl Display for Error {
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
fn fmt(&self, f: &mut Formatter<'_>) -> core::fmt::Result {
let (sw1, sw2) = self.response.trailer;

write!(
Expand All @@ -20,4 +20,5 @@ impl Display for Error {
}
}

#[cfg(feature = "std")]
impl std::error::Error for Error {}
4 changes: 4 additions & 0 deletions apdu-core/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
//! Core library for composing APDU commands and parsing their responses.

#![cfg_attr(not(feature = "std"), no_std)]

extern crate alloc;

mod command;
mod error;
mod response;
Expand Down

0 comments on commit 62732d7

Please sign in to comment.