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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
use crate::{datagram::*, geometry::Device, operation::DebugType};

/// Datagram for configure debug_output_idx
pub struct ConfigureDebugSettings<F: Fn(&Device) -> [DebugType; 4]> {
    f: F,
}

impl<F: Fn(&Device) -> [DebugType; 4]> ConfigureDebugSettings<F> {
    /// constructor
    pub const fn new(f: F) -> Self {
        Self { f }
    }

    // GRCOV_EXCL_START
    pub fn f(&self) -> &F {
        &self.f
    }
    // GRCOV_EXCL_STOP
}

impl<F: Fn(&Device) -> [DebugType; 4]> Datagram for ConfigureDebugSettings<F> {
    type O1 = crate::operation::DebugSettingOp<F>;
    type O2 = crate::operation::NullOp;

    fn timeout(&self) -> Option<Duration> {
        Some(Duration::from_millis(200))
    }

    fn operation(self) -> Result<(Self::O1, Self::O2), AUTDInternalError> {
        Ok((Self::O1::new(self.f), Self::O2::default()))
    }
}

mod old {
    #![allow(deprecated)]

    use crate::derive::Transducer;

    use super::*;

    /// Datagram for configure debug_output_idx
    #[deprecated(note = "Use DebugSettingOp instead", since = "22.1.0")]
    pub struct ConfigureDebugOutputIdx<F: Fn(&Device) -> Option<&Transducer>> {
        f: F,
    }

    impl<F: Fn(&Device) -> Option<&Transducer>> ConfigureDebugOutputIdx<F> {
        /// constructor
        pub const fn new(f: F) -> Self {
            Self { f }
        }

        // GRCOV_EXCL_START
        pub fn f(&self) -> &F {
            &self.f
        }
        // GRCOV_EXCL_STOP
    }

    impl<F: Fn(&Device) -> Option<&Transducer>> Datagram for ConfigureDebugOutputIdx<F> {
        type O1 = crate::operation::DebugOutIdxOp<F>;
        type O2 = crate::operation::NullOp;

        fn timeout(&self) -> Option<Duration> {
            Some(Duration::from_millis(200))
        }

        fn operation(self) -> Result<(Self::O1, Self::O2), AUTDInternalError> {
            Ok((Self::O1::new(self.f), Self::O2::default()))
        }
    }
}

#[allow(deprecated)]
pub use old::ConfigureDebugOutputIdx;