use crate::{
Error, Instruction, StatusCode, Uid,
client::{Authenticated, Card, command_encrypted_response_de_minimis},
io,
};
impl<'card, IoBackendT> Card<'card, IoBackendT, Authenticated>
where
IoBackendT: io::Backend,
{
pub async fn get_uid(&mut self) -> Result<Uid, Error<IoBackendT::Error>> {
let (status_code, response) = command_encrypted_response_de_minimis!(self, {
instruction: Instruction = Instruction::GetUid
}, 1, []);
#[cfg(feature = "tracing")]
tracing::debug!(
method = "get_uid",
status_code = format!("{:?}", status_code)
);
let response = &response[..7 + 4];
let response = io::check_crc32(response, &[&[status_code.into()]])?;
if status_code != StatusCode::Ack {
return Err(Error::BadStatusCode(status_code));
}
let uid: &Uid = response.try_into().map_err(|_| Error::BadSize)?;
Ok(*uid)
}
}