yubihsm 0.20.0

Pure Rust client for YubiHSM2 devices with support for HTTP and USB-based access to the device. Supports most HSM functionality including ECDSA, Ed25519, HMAC, and RSA.
Documentation
use serde::{de::DeserializeOwned, Serialize};

#[cfg(feature = "mockhsm")]
use crate::serialization::serialize;

mod code;
mod message;

pub use self::code::ResponseCode;
pub(crate) use self::message::ResponseMessage;
use crate::command::CommandCode;

/// Structured responses to `Command` messages sent from the HSM
pub(crate) trait Response: Serialize + DeserializeOwned + Sized {
    /// Command ID this response is for
    const COMMAND_CODE: CommandCode;

    /// Serialize a response type into a ResponseMessage
    #[cfg(feature = "mockhsm")]
    fn serialize(&self) -> ResponseMessage {
        ResponseMessage::success(Self::COMMAND_CODE, serialize(self).unwrap())
    }
}