1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
/*
 * File: no_modulation.rs
 * Project: primitives
 * Created Date: 22/05/2020
 * Author: Shun Suzuki
 * -----
 * Last Modified: 30/12/2020
 * Modified By: Shun Suzuki (suzuki@hapis.k.u-tokyo.ac.jp)
 * -----
 * Copyright (c) 2020 Hapis Lab. All rights reserved.
 *
 */

use super::super::Modulation;
use crate::core::configuration::Configuration;

/// Static amplitude.
pub struct NoModulation {
    buffer: [u8; 1],
    sent: usize,
}

impl NoModulation {
    pub fn create(amp: u8) -> Self {
        Self {
            buffer: [amp; 1],
            sent: 0,
        }
    }
}

impl Modulation for NoModulation {
    fn build(&mut self, _config: Configuration) {}

    fn buffer(&self) -> &[u8] {
        &self.buffer
    }

    fn sent(&mut self) -> &mut usize {
        &mut self.sent
    }
}