[refactor](trx-core): split RigCat into base trait + RigSdr extension
Extract 13 SDR-specific methods (set_center_freq, set_bandwidth, set_sdr_gain/lna/agc/squelch/nb, set_wfm_*, filter_state, get_spectrum, get_vchan_rds) into a new RigSdr trait. RigCat retains core CAT operations and gains as_sdr()/as_sdr_ref() for optional SDR access. Non-SDR backends no longer see SDR methods in their trait impl. https://claude.ai/code/session_01XzurkeuUmamBuhQwxVy7T4 Signed-off-by: Claude <noreply@anthropic.com>
This commit is contained in:
+36
-10
@@ -95,6 +95,10 @@ pub trait Rig {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Common CAT control operations any rig backend should implement.
|
/// Common CAT control operations any rig backend should implement.
|
||||||
|
///
|
||||||
|
/// This trait covers basic transceiver operations shared by all backends
|
||||||
|
/// (serial rigs, SDRs, etc.). SDR-specific controls live in the
|
||||||
|
/// [`RigSdr`] extension trait, accessible via [`as_sdr`](RigCat::as_sdr).
|
||||||
pub trait RigCat: Rig + Send {
|
pub trait RigCat: Rig + Send {
|
||||||
fn get_status<'a>(&'a mut self) -> RigStatusFuture<'a>;
|
fn get_status<'a>(&'a mut self) -> RigStatusFuture<'a>;
|
||||||
|
|
||||||
@@ -103,16 +107,6 @@ pub trait RigCat: Rig + Send {
|
|||||||
freq: Freq,
|
freq: Freq,
|
||||||
) -> Pin<Box<dyn Future<Output = DynResult<()>> + Send + 'a>>;
|
) -> Pin<Box<dyn Future<Output = DynResult<()>> + Send + 'a>>;
|
||||||
|
|
||||||
fn set_center_freq<'a>(
|
|
||||||
&'a mut self,
|
|
||||||
_freq: Freq,
|
|
||||||
) -> Pin<Box<dyn Future<Output = DynResult<()>> + Send + 'a>> {
|
|
||||||
Box::pin(std::future::ready(Err(
|
|
||||||
Box::new(response::RigError::not_supported("set_center_freq"))
|
|
||||||
as Box<dyn std::error::Error + Send + Sync>,
|
|
||||||
)))
|
|
||||||
}
|
|
||||||
|
|
||||||
fn set_mode<'a>(
|
fn set_mode<'a>(
|
||||||
&'a mut self,
|
&'a mut self,
|
||||||
mode: RigMode,
|
mode: RigMode,
|
||||||
@@ -150,6 +144,38 @@ pub trait RigCat: Rig + Send {
|
|||||||
None
|
None
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Return a mutable reference to the SDR extension trait, if this
|
||||||
|
/// backend supports SDR-specific operations. Default: `None`.
|
||||||
|
fn as_sdr(&mut self) -> Option<&mut dyn RigSdr> {
|
||||||
|
None
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Return an immutable reference to the SDR extension trait for
|
||||||
|
/// query-only operations (filter state, spectrum, RDS).
|
||||||
|
fn as_sdr_ref(&self) -> Option<&dyn RigSdr> {
|
||||||
|
None
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// SDR-specific extension operations.
|
||||||
|
///
|
||||||
|
/// Backends that support SDR features (center frequency, gain, AGC,
|
||||||
|
/// squelch, noise blanker, spectrum output, etc.) implement this trait.
|
||||||
|
/// Access it from a `dyn RigCat` via [`RigCat::as_sdr`].
|
||||||
|
///
|
||||||
|
/// All methods have default implementations returning "not supported"
|
||||||
|
/// or `None`, so backends need only override what they actually support.
|
||||||
|
pub trait RigSdr: Send {
|
||||||
|
fn set_center_freq<'a>(
|
||||||
|
&'a mut self,
|
||||||
|
_freq: Freq,
|
||||||
|
) -> Pin<Box<dyn Future<Output = DynResult<()>> + Send + 'a>> {
|
||||||
|
Box::pin(std::future::ready(Err(
|
||||||
|
Box::new(response::RigError::not_supported("set_center_freq"))
|
||||||
|
as Box<dyn std::error::Error + Send + Sync>,
|
||||||
|
)))
|
||||||
|
}
|
||||||
|
|
||||||
fn set_bandwidth<'a>(
|
fn set_bandwidth<'a>(
|
||||||
&'a mut self,
|
&'a mut self,
|
||||||
_bandwidth_hz: u32,
|
_bandwidth_hz: u32,
|
||||||
|
|||||||
Reference in New Issue
Block a user