use serde::{Serialize, Deserialize};
use serde_json::Value as JsonValue;
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Default)]
pub enum ResultCode {
#[default]
Success,
RemovedCard,
ResetCard,
UnpoweredCard,
UnresponsiveCard,
UnsupportedCard,
ReaderUnavailable,
SharingViolation,
NotTransacted,
NoSmartcard,
ProtoMismatch,
SystemCancelled,
NotReady,
Cancelled,
InsufficientBuffer,
InvalidHandle,
InvalidParameter,
InvalidValue,
NoMemory,
Timeout,
UnknownReader,
UnsupportedFeature,
NoReadersAvailable,
ServiceStopped,
NoService,
CommError,
InternalError,
ServerTooBusy,
Unexpected,
Shutdown,
UnknownCard,
Unknown,
}
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Default)]
pub enum ShareMode {
#[default]
Shared,
Exclusive,
Direct,
}
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Default)]
pub enum Disposition {
#[default]
LeaveCard,
ResetCard,
UnpowerCard,
EjectCard,
}
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Default)]
pub enum ConnectionState {
#[default]
Absent,
Present,
Swallowed,
Powered,
Negotiable,
Specific,
}
#[derive(Debug, Clone, Serialize, Deserialize, Default)]
#[serde(rename_all = "camelCase")]
pub struct ReaderStateFlags {
#[serde(skip_serializing_if = "Option::is_none")]
pub unaware: Option<bool>,
#[serde(skip_serializing_if = "Option::is_none")]
pub ignore: Option<bool>,
#[serde(skip_serializing_if = "Option::is_none")]
pub changed: Option<bool>,
#[serde(skip_serializing_if = "Option::is_none")]
pub unknown: Option<bool>,
#[serde(skip_serializing_if = "Option::is_none")]
pub unavailable: Option<bool>,
#[serde(skip_serializing_if = "Option::is_none")]
pub empty: Option<bool>,
#[serde(skip_serializing_if = "Option::is_none")]
pub present: Option<bool>,
#[serde(skip_serializing_if = "Option::is_none")]
pub exclusive: Option<bool>,
#[serde(skip_serializing_if = "Option::is_none")]
pub inuse: Option<bool>,
#[serde(skip_serializing_if = "Option::is_none")]
pub mute: Option<bool>,
#[serde(skip_serializing_if = "Option::is_none")]
pub unpowered: Option<bool>,
}
#[derive(Debug, Clone, Serialize, Deserialize, Default)]
#[serde(rename_all = "camelCase")]
pub struct ProtocolSet {
#[serde(skip_serializing_if = "Option::is_none")]
pub t0: Option<bool>,
#[serde(skip_serializing_if = "Option::is_none")]
pub t1: Option<bool>,
#[serde(skip_serializing_if = "Option::is_none")]
pub raw: Option<bool>,
}
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Default)]
pub enum Protocol {
#[default]
T0,
T1,
Raw,
}
#[derive(Debug, Clone, Serialize, Deserialize, Default)]
#[serde(rename_all = "camelCase")]
pub struct ReaderStateIn {
pub reader: String,
pub currentState: ReaderStateFlags,
pub currentInsertionCount: u64,
}
#[derive(Debug, Clone, Serialize, Deserialize, Default)]
#[serde(rename_all = "camelCase")]
pub struct ReaderStateOut {
pub reader: String,
pub eventState: ReaderStateFlags,
pub eventCount: u64,
pub atr: String,
}
#[derive(Debug, Clone, Serialize, Deserialize, Default)]
pub struct EnableParams {}
impl EnableParams { pub const METHOD: &'static str = "SmartCardEmulation.enable"; }
impl crate::CdpCommand for EnableParams {
const METHOD: &'static str = "SmartCardEmulation.enable";
type Response = crate::EmptyReturns;
}
#[derive(Debug, Clone, Serialize, Deserialize, Default)]
pub struct DisableParams {}
impl DisableParams { pub const METHOD: &'static str = "SmartCardEmulation.disable"; }
impl crate::CdpCommand for DisableParams {
const METHOD: &'static str = "SmartCardEmulation.disable";
type Response = crate::EmptyReturns;
}
#[derive(Debug, Clone, Serialize, Deserialize, Default)]
#[serde(rename_all = "camelCase")]
pub struct ReportEstablishContextResultParams {
pub requestId: String,
pub contextId: u64,
}
impl ReportEstablishContextResultParams { pub const METHOD: &'static str = "SmartCardEmulation.reportEstablishContextResult"; }
impl crate::CdpCommand for ReportEstablishContextResultParams {
const METHOD: &'static str = "SmartCardEmulation.reportEstablishContextResult";
type Response = crate::EmptyReturns;
}
#[derive(Debug, Clone, Serialize, Deserialize, Default)]
#[serde(rename_all = "camelCase")]
pub struct ReportReleaseContextResultParams {
pub requestId: String,
}
impl ReportReleaseContextResultParams { pub const METHOD: &'static str = "SmartCardEmulation.reportReleaseContextResult"; }
impl crate::CdpCommand for ReportReleaseContextResultParams {
const METHOD: &'static str = "SmartCardEmulation.reportReleaseContextResult";
type Response = crate::EmptyReturns;
}
#[derive(Debug, Clone, Serialize, Deserialize, Default)]
#[serde(rename_all = "camelCase")]
pub struct ReportListReadersResultParams {
pub requestId: String,
pub readers: Vec<String>,
}
impl ReportListReadersResultParams { pub const METHOD: &'static str = "SmartCardEmulation.reportListReadersResult"; }
impl crate::CdpCommand for ReportListReadersResultParams {
const METHOD: &'static str = "SmartCardEmulation.reportListReadersResult";
type Response = crate::EmptyReturns;
}
#[derive(Debug, Clone, Serialize, Deserialize, Default)]
#[serde(rename_all = "camelCase")]
pub struct ReportGetStatusChangeResultParams {
pub requestId: String,
pub readerStates: Vec<ReaderStateOut>,
}
impl ReportGetStatusChangeResultParams { pub const METHOD: &'static str = "SmartCardEmulation.reportGetStatusChangeResult"; }
impl crate::CdpCommand for ReportGetStatusChangeResultParams {
const METHOD: &'static str = "SmartCardEmulation.reportGetStatusChangeResult";
type Response = crate::EmptyReturns;
}
#[derive(Debug, Clone, Serialize, Deserialize, Default)]
#[serde(rename_all = "camelCase")]
pub struct ReportBeginTransactionResultParams {
pub requestId: String,
pub handle: i64,
}
impl ReportBeginTransactionResultParams { pub const METHOD: &'static str = "SmartCardEmulation.reportBeginTransactionResult"; }
impl crate::CdpCommand for ReportBeginTransactionResultParams {
const METHOD: &'static str = "SmartCardEmulation.reportBeginTransactionResult";
type Response = crate::EmptyReturns;
}
#[derive(Debug, Clone, Serialize, Deserialize, Default)]
#[serde(rename_all = "camelCase")]
pub struct ReportPlainResultParams {
pub requestId: String,
}
impl ReportPlainResultParams { pub const METHOD: &'static str = "SmartCardEmulation.reportPlainResult"; }
impl crate::CdpCommand for ReportPlainResultParams {
const METHOD: &'static str = "SmartCardEmulation.reportPlainResult";
type Response = crate::EmptyReturns;
}
#[derive(Debug, Clone, Serialize, Deserialize, Default)]
#[serde(rename_all = "camelCase")]
pub struct ReportConnectResultParams {
pub requestId: String,
pub handle: i64,
#[serde(skip_serializing_if = "Option::is_none")]
pub activeProtocol: Option<Protocol>,
}
impl ReportConnectResultParams { pub const METHOD: &'static str = "SmartCardEmulation.reportConnectResult"; }
impl crate::CdpCommand for ReportConnectResultParams {
const METHOD: &'static str = "SmartCardEmulation.reportConnectResult";
type Response = crate::EmptyReturns;
}
#[derive(Debug, Clone, Serialize, Deserialize, Default)]
#[serde(rename_all = "camelCase")]
pub struct ReportDataResultParams {
pub requestId: String,
pub data: String,
}
impl ReportDataResultParams { pub const METHOD: &'static str = "SmartCardEmulation.reportDataResult"; }
impl crate::CdpCommand for ReportDataResultParams {
const METHOD: &'static str = "SmartCardEmulation.reportDataResult";
type Response = crate::EmptyReturns;
}
#[derive(Debug, Clone, Serialize, Deserialize, Default)]
#[serde(rename_all = "camelCase")]
pub struct ReportStatusResultParams {
pub requestId: String,
pub readerName: String,
pub state: ConnectionState,
pub atr: String,
#[serde(skip_serializing_if = "Option::is_none")]
pub protocol: Option<Protocol>,
}
impl ReportStatusResultParams { pub const METHOD: &'static str = "SmartCardEmulation.reportStatusResult"; }
impl crate::CdpCommand for ReportStatusResultParams {
const METHOD: &'static str = "SmartCardEmulation.reportStatusResult";
type Response = crate::EmptyReturns;
}
#[derive(Debug, Clone, Serialize, Deserialize, Default)]
#[serde(rename_all = "camelCase")]
pub struct ReportErrorParams {
pub requestId: String,
pub resultCode: ResultCode,
}
impl ReportErrorParams { pub const METHOD: &'static str = "SmartCardEmulation.reportError"; }
impl crate::CdpCommand for ReportErrorParams {
const METHOD: &'static str = "SmartCardEmulation.reportError";
type Response = crate::EmptyReturns;
}