basic_dsp_vector/
meta.rs

1use super::vector_types::*;
2
3/// Marker for types containing real data.
4#[derive(Debug, Clone, PartialEq)]
5pub struct Real;
6impl NumberSpace for Real {
7    fn is_complex(&self) -> bool {
8        false
9    }
10    fn to_complex(&mut self) {}
11    fn to_real(&mut self) {}
12}
13impl RealNumberSpace for Real {}
14
15/// Marker for types containing complex data.
16#[derive(Debug, Clone, PartialEq)]
17pub struct Complex;
18impl NumberSpace for Complex {
19    fn is_complex(&self) -> bool {
20        true
21    }
22    fn to_complex(&mut self) {}
23    fn to_real(&mut self) {}
24}
25impl ComplexNumberSpace for Complex {}
26
27/// Marker for types containing real or complex data.
28#[derive(Debug, Clone, PartialEq)]
29pub struct RealOrComplex {
30    pub is_complex_current: bool,
31}
32impl NumberSpace for RealOrComplex {
33    fn is_complex(&self) -> bool {
34        self.is_complex_current
35    }
36
37    fn to_complex(&mut self) {
38        self.is_complex_current = true;
39    }
40
41    fn to_real(&mut self) {
42        self.is_complex_current = false;
43    }
44}
45impl RealNumberSpace for RealOrComplex {}
46impl ComplexNumberSpace for RealOrComplex {}
47
48/// Marker for types containing time data.
49#[derive(Debug, Clone, PartialEq)]
50pub struct Time;
51impl Domain for Time {
52    fn domain(&self) -> DataDomain {
53        DataDomain::Time
54    }
55    fn to_freq(&mut self) {}
56    fn to_time(&mut self) {}
57}
58impl TimeDomain for Time {}
59
60/// Marker for types containing frequency data.
61#[derive(Debug, Clone, PartialEq)]
62pub struct Freq;
63impl Domain for Freq {
64    fn domain(&self) -> DataDomain {
65        DataDomain::Frequency
66    }
67    fn to_time(&mut self) {}
68    fn to_freq(&mut self) {}
69}
70impl FrequencyDomain for Freq {}
71
72/// Marker for types containing time or frequency data.
73#[derive(Debug, Clone, PartialEq)]
74pub struct TimeOrFreq {
75    pub domain_current: DataDomain,
76}
77impl Domain for TimeOrFreq {
78    fn domain(&self) -> DataDomain {
79        self.domain_current
80    }
81
82    fn to_freq(&mut self) {
83        self.domain_current = DataDomain::Frequency;
84    }
85
86    fn to_time(&mut self) {
87        self.domain_current = DataDomain::Time;
88    }
89}
90
91impl TimeDomain for TimeOrFreq {}
92impl FrequencyDomain for TimeOrFreq {}
93
94impl PosEq<Real> for Real {}
95impl PosEq<RealOrComplex> for Real {}
96impl PosEq<Real> for RealOrComplex {}
97impl PosEq<Complex> for RealOrComplex {}
98impl PosEq<RealOrComplex> for RealOrComplex {}
99impl PosEq<Complex> for Complex {}
100impl PosEq<RealOrComplex> for Complex {}
101
102impl PosEq<Time> for Time {}
103impl PosEq<TimeOrFreq> for Time {}
104impl PosEq<Time> for TimeOrFreq {}
105impl PosEq<Freq> for TimeOrFreq {}
106impl PosEq<TimeOrFreq> for TimeOrFreq {}
107impl PosEq<Freq> for Freq {}
108impl PosEq<TimeOrFreq> for Freq {}