-
Fix
SCardControl
on mac OS (use the newerSCardControl132
symbol).Contributed by Tang Cheng.
-
Make
pcsc::ffi
public again; accidentally regressed in 2.8.1.Contributed by Ignacio Casal Quinteiro.
-
Fix possible panics in
list_readers_owned
andget_attribute_owned
functions, and handling of null buffers inlist_readers
andget_attribute
.Reported by @ n-eq in issue #9.
-
The
pcsc-sys
crate is now reexported from thepcsc
crate aspcsc::ffi
.Contributed by Basix.
-
Added
Card::transmit2()
, which is likeCard::transmit()
, but also returns the required receive buffer size onError::InsufficientBuffer
errors.Make sure to heed the note on the function's documentation if you intend to use it!
Contributed by Nicolas Dusart.
-
Added
ReaderState::current_state() -> State
getter. This returns the last current state that was set usingsync_current_state()
.Note that for observing the current state as reported by
get_status_change()
, you wantevent_state()
, notcurrent_state()
.Contributed by Ilya Averyanov.
-
ReaderState
is nowSend
andSync
. -
Bumped the minimum supported rust version (MSRV) 1.20 -> 1.38.
-
Added
Card::transaction2()
, which is likeCard::transaction()
, but also returns the&mut self
on error. Without it is is difficult (impossible) to encapsulate a retry-loop of trying to acquire a transaction in a function, at least until some borrow-checker improvements end our woes.Contributed by Neal H. Walfield.
- Un-deprecated the
pcsc::Status
type. It was previously disabled due to a portability hazard; now Windows is made to behave like other platforms, although only one bit is ever set.
- Added
status.status()
accessor toCardStatus
(return value ofCard::status2()
) andCardStatusOwned
(return value ofCard::status2_owned()
).
-
Added owned versions of several functions:
Context::list_readers
->Context::list_readers_owned
Card::get_attribute
->Card::get_attribute_owned
Card::status2
->Card::status2_owned
You can use them if you don't want to deal with lengths and buffers and just allocate.
Contributed by Robin Krahl.
-
Added support for direct connections to a reader (without a card attached).
This enables setting control parameters on readers which support it, for example. Transmitting with custom protocols on such connections is not supported however.
Such connections use
ShareMode::Direct
andProtocols::UNDEFINED
.For this purpose the following changes were made:
-
Added a
CardStatus::protocol2()
which returnsOption<Protocol>
, as opposed toCardStatus::protocol()
which now panics when missing protocol. -
Made
Card::status()
panic when missing protocol. This function is deprecated (useCard::status2()
instead). -
Made
Card::transmit()
panic when missing protocol.
-
-
Fixed wrong result from
Error::into_raw()
on 64-bit Linux/BSD.An incorrect cast caused a bit extension to be made when
LONG
is 64 bit. This means 64-bit platforms other than Windows and macOS (whereLONG
is always 32 bit).Internally,
Error::into_raw()
is used inContext::list_readers()
andContext::list_readers_len()
, which had a bug as a result: instead of returning empty iterator/Ok(0)
when no readers are available,Err(Error::NoReadersAvailable)
was returned.
-
Deprecated the
Card::status()
function and theStatus
type. Turns outStatus
is not a bitmask on Windows, so the interface was not portable and unfixable.These were replaced with
Card::status2()
, which returns a newCardStatus
type. This interface is portable, and also exposes the ATR and reader names. However, it doesn't yet expose the actual status -- if you need it, please open an issue. -
Implemented
Debug
for theReaderNames
iterator struct.
-
Added
SCARD_ATR_LENGTH
constant. -
Fixed values of card state constants (
SCARD_PRESENT
and friends) on Windows. They were entirely wrong there. -
Fixed value of
SCARD_PROTOCOL_RAW
on Windows.
- Added a
ctl_function()
, a wrapper for theSCARD_CTL_CODE
PCSC API.
-
Added bindings for the
SCARD_CTL_CODE
PCSC API. -
Added a way to specify which PCSC library to use directly instead of using pkg-config, if needed. The build script now checks for two environment variables,
PCSC_LIB_DIR
andPCSC_LIB_NAME
. So the crate documentation for details.
- Fixed bug where card.disconnect() would keep the associated Context alive (leaked a strong reference).
- Added support for getting the ATR (Answer To Reset) from a
ReaderState
.
-
BREAKING CHANGE (
pcsc
) Remove the lifetime from theCard
type.This lifetime made the common case of bundling a
Context
and aCard
in the same struct very difficult, due to Rust's current inability to express "self-referential structs".Instead of the lifetime, a
Card
now holds anArc
reference to itsContext
. The consequences of this are:-
Context
now implementsClone
. The implementation is anArc::clone
. -
The PCSC context is only released once the last clone is dropped.
-
The function
Context::release()
fails with anError::CantDispose
if called while there are other clones alive. -
The "transitive"
'card
lifetime ofTransaction
is removed.
The migrate your code, replace all instances of
Card<'lifetime>
withCard
, if you had to explicitly specify the lifetime.Note that the
'tx
lifetime ofTransaction
remains. Transactions are normally short-lived and well-scoped, so using a static lifetime makes better sense in this case.Reported by @a-dma in issue #9.
-
-
BREAKING CHANGE (
pcsc-sys
) Fix the types ofSCARDCONTEXT
andSCARDHANDLE
on Windows.Previously they were (effectively) defined as
i32
, but the correct definition isusize
. Hence on all Windows platforms, the sign is different (not really a problem); and on 64 bits, the width is different (wouldn't work).While this is technically a breaking change, this should be transparent and binaries for Windows 64 bits wouldn't have worked anyway, so we avoid a major version bump which is a headache for FFI crates.
Reported and debugged by @ndusart in issue #6.
-
(
pcsc
) Depend onpcsc-sys >= 1.0.1
to discourage using the broken1.0.0
.
-
BREAKING CHANGE Update bitflags to version 1. This makes the flag types easier to use, and improves the documentation.
Since bitflags now uses associated constants, Rust >= 1.20 is required.
Example for updating:
STATE_UNAWARE
->State::UNAWARE
. -
The
pcsc-sys
crate is also promoted to 1.0.0, without changes.
-
pcsc-sys
: AddedSCardControl()
bindings. -
Added
Card::control()
, a wrapper overSCardControl()
. -
pcsc-sys
: Improved build target detection in the build script.
-
Fixed errors in the macOS bindings. In particular, wrong integer types were used, and some structs had incorrect padding.
All discovered problems were fixed; the library now works correctly on macOS.
Reported and debugged by @RokLenarcic in issue #4.
-
The function
ReaderState::new()
now takesInto<CString>
instead of&CStr
. Previously the&CStr
was turned into aCString
internally; the new form is more explicit and can avoid an allocation if aCString
is passed directly.
Initial stable release.