Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add find_device function #56

Merged
merged 5 commits into from
Nov 16, 2022
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Change Utf8 to HWIError and add no_run to find_device example
  • Loading branch information
yukibtc committed Nov 16, 2022
commit 6c4d1bf54fba0cc709e8b4ffce908fad3d9545a0
12 changes: 9 additions & 3 deletions src/interface.rs
Original file line number Diff line number Diff line change
Expand Up @@ -134,13 +134,19 @@ impl HWIClient {
/// [`enumerate`](HWIClient::enumerate).
///
/// Setting `expert` to `true` will enable additional output for some commands.
/// ```
/// ```no_run
/// # use hwi::HWIClient;
/// # use hwi::types::*;
/// # use hwi::error::Error;
/// # fn main() -> Result<(), Error> {
/// let device_type = "trezor";
/// let client = HWIClient::find_device(None, Some(device_type), None, true, hwi::types::HWIChain::Test)?;
/// let client = HWIClient::find_device(
/// None,
/// Some(device_type),
/// None,
/// true,
/// hwi::types::HWIChain::Test,
/// )?;
/// let xpub = client.get_master_xpub(HWIAddressType::Tap, 0)?;
/// println!(
/// "I can see a {} here, and its xpub is {}",
Expand Down Expand Up @@ -172,7 +178,7 @@ impl HWIClient {
.call1(py, client_args)?;

if client.is_none(py) {
return Err(Error::Utf8("Device not found".to_string()));
return Err(Error::HWIError("Device not found".to_string()));
}

Ok(HWIClient {
Expand Down