~ireas/nitrokey-rs

nitrokey-rs/tests/lib.rs -rw-r--r-- 746 bytes
Merge branch 'release-0.4.0'
Merge branch 'connection-manager-mut' into next

Refactor the connection management to prevent multiple device
connections at the same time.

RFC: https://lists.sr.ht/~ireas/nitrokey-rs-dev/%3C20190126174327.tbuyk2s535kfiqm4%40localhost%3E
Add Manager struct to manage Nitrokey connections

As part of the connection refactoring, we introduce the Manager struct
that deals with connection management.  To make sure there can be only
once instance of the manager, we add a global static Mutex that holds
the single Manager instance.  We use the struct to ensure that the user
can only connect to one device at a time.

This also changes the Error::PoisonError variant to store the
sync::PoisonError.  This allows the user to call into_inner on the
PoisonError to retrieve the MutexGuard and to ignore the error (for
example useful during testing).
Add unwrap_ok macro to replace unwrap in unit tests

The unwrap error message is not very useful.  This patch adds the
unwrap_ok macro that is basically the same as unwrap but prints a more
readable error message.
Add license and copyright information

This patch adds license and copyright information to all files to make
nitrokey-rs compliant with the REUSE practices [0].

[0] https://reuse.software/practices/2.0/
Return UTF-8 error if libnitrokey returns an invalid string

Previously, we used lossy UTF-8 conversion.  Yet the user should be
notified if we have a problem instead of silently changing the data.
Therefore, we now return an error if we enocunter an invalid UTF-8
string.  This leads to a change in `get_library_version`’s signature.
Document and test empty Git versions

If libnitrokey has not been built from a clone of the Git repository,
the Git version string may be empty.
Add the get_library_version function

This patch adds the get_library_version function to the main library
module that queries and returns the libnitrokey version.  As the version
fields are static values, we fetch them all at the same time and do not
provide getters for the individual fields.