diff options
| author | Yuval Adam <_@yuv.al> | 2021-04-25 09:28:58 +0300 |
|---|---|---|
| committer | Yuval Adam <_@yuv.al> | 2021-04-25 09:28:58 +0300 |
| commit | 47934e3c7ca64bfb82fbcede47491084a9e9f266 (patch) | |
| tree | cb2c905375ea35d30654ffb32f19710e4be46410 /src/lib.rs | |
| parent | 0a6bfe601e51f4c9475bec03d077e72ed7c46823 (diff) | |
Restore dynamic trait polymorphism with handles in functions
Diffstat (limited to 'src/lib.rs')
| -rw-r--r-- | src/lib.rs | 11 |
1 files changed, 7 insertions, 4 deletions
@@ -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) { |
