pcsc: Allow a transaction to own the underlying card.
-
Since Rust's support for self-referencial data structures is weak, there are cases where it is useful for a transaction to own the card and not just for it to hold a mutable reference. In these cases, the caller needs to explicitly end the transaction to recover the underlying card, but that is acceptable.
-
Generalize
Transactionto be generic over aBorrowMut<Card>. Add new functionsCard::begin_transaction_ownedandCard::begin_transaction2_ownedto create this type of transaction. ChangeTransaction::endto return the underlying card. And, add a variant,Transaction::end2, to unconditionally return the underlying card independent of whether ending the transaction succeeded.
I left a comment regarding this PR here: https://github.com/bluetech/pcsc-rust/issues/28#issuecomment-1059736167