pcsc-rust icon indicating copy to clipboard operation
pcsc-rust copied to clipboard

pcsc: Allow a transaction to own the underlying card.

Open nwalfield opened this issue 3 years ago • 1 comments

  • 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 Transaction to be generic over a BorrowMut<Card>. Add new functions Card::begin_transaction_owned and Card::begin_transaction2_owned to create this type of transaction. Change Transaction::end to return the underlying card. And, add a variant, Transaction::end2, to unconditionally return the underlying card independent of whether ending the transaction succeeded.

nwalfield avatar Feb 16 '22 16:02 nwalfield

I left a comment regarding this PR here: https://github.com/bluetech/pcsc-rust/issues/28#issuecomment-1059736167

bluetech avatar Mar 05 '22 10:03 bluetech