From 10d566acd2bcd35c8969fc7991b050da01ceb74c Mon Sep 17 00:00:00 2001 From: Yuval Adam <_@yuv.al> Date: Fri, 16 Apr 2021 15:25:19 +0300 Subject: Pass handle as reference to tuner and implement Drop --- src/devices/r820t.rs | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) (limited to 'src/devices') diff --git a/src/devices/r820t.rs b/src/devices/r820t.rs index 92ba509..a257b56 100644 --- a/src/devices/r820t.rs +++ b/src/devices/r820t.rs @@ -3,9 +3,9 @@ use usb::RtlSdrDeviceHandle; const R82XX_IF_FREQ: u32 = 3570000; -pub struct R820T { +pub struct R820T<'a> { pub device: DeviceInfo, - pub handle: RtlSdrDeviceHandle, + pub handle: &'a RtlSdrDeviceHandle, } pub const DEVICE_INFO: DeviceInfo = DeviceInfo { @@ -16,8 +16,8 @@ pub const DEVICE_INFO: DeviceInfo = DeviceInfo { check_val: 0x69, }; -impl R820T { - pub fn new(handle: RtlSdrDeviceHandle) -> R820T { +impl<'a> R820T<'a> { + pub fn new(handle: &'a RtlSdrDeviceHandle) -> R820T<'a> { R820T { device: DEVICE_INFO, handle: handle, @@ -25,7 +25,11 @@ impl R820T { } } -impl Device for R820T { +impl<'a> Drop for R820T<'a> { + fn drop(&mut self) {} +} + +impl<'a> Device for R820T<'a> { fn init(&self) { // disable Zero-IF mode self.handle.demod_write_reg(1, 0xb1, 0x1a, 1); -- cgit v1.3.1