Struct pcsc::Card
[−]
[src]
pub struct Card<'ctx> { /* fields omitted */ }
A connection to a smart card.
This structure wraps SCARDHANDLE
.
Methods
impl<'ctx> Card<'ctx>
[src]
fn transaction<'tx>(&'tx mut self) -> Result<Transaction<'tx, 'ctx>, Error>
Start a new exclusive transaction with the card.
Operations on the card for the duration of the transaction
can only be performed through the returned Transaction
.
fn reconnect(
&mut self,
share_mode: ShareMode,
preferred_protocols: Protocols,
initialization: Disposition
) -> Result<(), Error>
&mut self,
share_mode: ShareMode,
preferred_protocols: Protocols,
initialization: Disposition
) -> Result<(), Error>
fn disconnect(self, disposition: Disposition) -> Result<(), (Card<'ctx>, Error)>
Disconnect from the card.
In case of error, ownership of the card is returned to the caller.
This function wraps SCardDisconnect
(pcsclite, MSDN).
Note
Card
implements Drop
which automatically disconnects the card
using Disposition::ResetCard
; you only need to call this
function if you want to handle errors or use a different
disposition method.
fn status(&self) -> Result<(Status, Protocol), Error>
fn get_attribute<'buf>(
&self,
attribute: Attribute,
buffer: &'buf mut [u8]
) -> Result<&'buf [u8], Error>
&self,
attribute: Attribute,
buffer: &'buf mut [u8]
) -> Result<&'buf [u8], Error>
Get an attribute of the card or card reader.
buffer
is a buffer that should be large enough for the attribute
data. The function get_attribute_len
can be used to find the
exact required length.
Returns a slice into buffer
containing the attribute data.
If the buffer is not large enough, Error::InsufficientBuffer
is
returned.
fn get_attribute_len(&self, attribute: Attribute) -> Result<usize, Error>
Get the needed length of a buffer to be passed to get_attribute
.
fn set_attribute(
&self,
attribute: Attribute,
attribute_data: &[u8]
) -> Result<(), Error>
&self,
attribute: Attribute,
attribute_data: &[u8]
) -> Result<(), Error>
fn transmit<'buf>(
&self,
send_buffer: &[u8],
receive_buffer: &'buf mut [u8]
) -> Result<&'buf [u8], Error>
&self,
send_buffer: &[u8],
receive_buffer: &'buf mut [u8]
) -> Result<&'buf [u8], Error>
Transmit an APDU command to the card.
receive_buffer
is a buffer that should be large enough to hold
the APDU response.
Returns a slice into receive_buffer
containing the APDU
response.
If receive_buffer
is not large enough to hold the APDU response,
Error::InsufficientBuffer
is returned.
fn control<'buf>(
&self,
control_code: DWORD,
send_buffer: &[u8],
receive_buffer: &'buf mut [u8]
) -> Result<&'buf [u8], Error>
&self,
control_code: DWORD,
send_buffer: &[u8],
receive_buffer: &'buf mut [u8]
) -> Result<&'buf [u8], Error>
Sends a command directly to the reader (driver).
receive_buffer
is a buffer that should be large enough to hold
the response.
Returns a slice into receive_buffer
containing the response.
If receive_buffer
is not large enough to hold the response,
Error::InsufficientBuffer
is returned.