use super::{AuthenticationState, Card, CardIoDefault};
use crate::{Error, StatusCode, io};
#[derive(Copy, Clone, Debug, PartialEq)]
pub struct Unauthenticated;
impl AuthenticationState for Unauthenticated {}
impl<IoBackendT> CardIoDefault<IoBackendT> for Card<IoBackendT, Unauthenticated>
where
IoBackendT: io::Backend,
{
async fn default_exchange_multi<'a>(
&mut self,
output: &'a mut [u8],
header: &[u8],
data: &[&[u8]],
) -> Result<(StatusCode, &'a [u8]), Error<IoBackendT::Error>> {
io::plain_multi(&self.card, output, header, data).await
}
async fn default_exchange_multi_de_minimis<'a>(
&'a mut self,
header: &[u8],
data: &[&[u8]],
) -> Result<(StatusCode, &'a [u8]), Error<IoBackendT::Error>> {
io::plain_multi(&self.card, &mut self.buf, header, data).await
}
}
impl<IoBackendT> Card<IoBackendT, Unauthenticated>
where
IoBackendT: io::Backend,
{
pub fn new(card: IoBackendT) -> Self {
Self {
card,
buf: [0; 60],
application_id: [0x00, 0x00, 0x00],
authentication: Unauthenticated,
}
}
}