summaryrefslogtreecommitdiff
path: root/src/lib.rs
diff options
context:
space:
mode:
authorYuval Adam <_@yuv.al>2021-04-25 09:28:58 +0300
committerYuval Adam <_@yuv.al>2021-04-25 09:28:58 +0300
commit47934e3c7ca64bfb82fbcede47491084a9e9f266 (patch)
treecb2c905375ea35d30654ffb32f19710e4be46410 /src/lib.rs
parent0a6bfe601e51f4c9475bec03d077e72ed7c46823 (diff)
Restore dynamic trait polymorphism with handles in functions
Diffstat (limited to 'src/lib.rs')
-rw-r--r--src/lib.rs11
1 files changed, 7 insertions, 4 deletions
diff --git a/src/lib.rs b/src/lib.rs
index 9fe48b3..65d545c 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -16,17 +16,17 @@ const KNOWN_DEVICES: [(u16, u16, &str); 2] = [
];
pub struct RtlSdr {
- // handle: RtlSdrDeviceHandle,
+ handle: RtlSdrDeviceHandle,
}
impl RtlSdr {
pub fn new() -> RtlSdr {
pretty_env_logger::init();
- let handle = Self::open_device();
- RtlSdr {}
+ let handle = Self::open_device().unwrap();
+ RtlSdr { handle }
}
- pub fn open_device() {
+ pub fn open_device() -> Option<RtlSdrDeviceHandle> {
for dev in rusb::devices().unwrap().iter() {
let desc = dev.device_descriptor().unwrap();
let vid = desc.vendor_id();
@@ -50,9 +50,12 @@ impl RtlSdr {
handle.set_i2c_repeater(true);
handle.init_tuner();
+
+ return Some(handle);
}
}
}
+ None
}
// pub fn set_sample_rate(&self, samp_rate: u32) {