aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--CHANGELOG.md1
-rw-r--r--src/device.rs20
2 files changed, 15 insertions, 6 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 365b864..92a4dac 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -19,6 +19,7 @@
instantiation impossible.
- Refactor and clean up internal code:
- Prefer using the `Into` trait over numeric casting.
+ - Add `Pro::new` and `Storage::new` functions.
# v0.3.4 (2019-01-20)
- Fix authentication methods that assumed that `char` is signed.
diff --git a/src/device.rs b/src/device.rs
index 287268b..2abf801 100644
--- a/src/device.rs
+++ b/src/device.rs
@@ -788,12 +788,16 @@ impl Pro {
pub fn connect() -> Result<Pro, Error> {
// TODO: maybe Option instead of Result?
match connect_enum(Model::Pro) {
- true => Ok(Pro {
- marker: marker::PhantomData,
- }),
+ true => Ok(Pro::new()),
false => Err(CommunicationError::NotConnected.into()),
}
}
+
+ fn new() -> Pro {
+ Pro {
+ marker: marker::PhantomData,
+ }
+ }
}
impl Drop for Pro {
@@ -836,13 +840,17 @@ impl Storage {
pub fn connect() -> Result<Storage, Error> {
// TODO: maybe Option instead of Result?
match connect_enum(Model::Storage) {
- true => Ok(Storage {
- marker: marker::PhantomData,
- }),
+ true => Ok(Storage::new()),
false => Err(CommunicationError::NotConnected.into()),
}
}
+ fn new() -> Storage {
+ Storage {
+ marker: marker::PhantomData,
+ }
+ }
+
/// Changes the update PIN.
///
/// The update PIN is used to enable firmware updates. Unlike the user and the admin PIN, the