diff options
| author | Yuval Adam <_@yuv.al> | 2021-04-16 17:43:32 +0300 |
|---|---|---|
| committer | Yuval Adam <_@yuv.al> | 2021-04-17 10:33:57 +0300 |
| commit | cc3a300afcba8fffaee5feb5f56792cfd697bf28 (patch) | |
| tree | e73c759cc54ba3f59dcd5f765f03cb0f2163d5c6 /src/lib.rs | |
| parent | 01824ebaa3096d40a962b921ed239241f92e1076 (diff) | |
Dynamic dispatch of tuner
Diffstat (limited to 'src/lib.rs')
| -rw-r--r-- | src/lib.rs | 6 |
1 files changed, 3 insertions, 3 deletions
@@ -51,9 +51,10 @@ impl RtlSdr { handle.init_baseband(); handle.set_i2c_repeater(true); - let tuner = match self.search_tuner(&handle) { + let tuner: Box<dyn Tuner> = match self.search_tuner(&handle) { Some(tuner) => match tuner { - "r820t" => Some(r820t::R820T::new(&handle)), + r820t::TUNER_ID => Box::new(r820t::R820T::new(&handle)), + fc0013::TUNER_ID => Box::new(fc0013::FC0013::new(&handle)), _ => { println!("No valid tuner found"); return; @@ -65,7 +66,6 @@ impl RtlSdr { } }; - let tuner = tuner.unwrap(); tuner.init(); // handle.deinit_baseband(); |
