cog_task/action/core/
nil.rs

1use crate::action::{Action, StatefulAction};
2use crate::comm::{QWriter, Signal};
3use crate::resource::{IoManager, ResourceManager};
4use crate::server::{AsyncSignal, Config, State, SyncSignal};
5use eyre::Result;
6use serde::{Deserialize, Serialize};
7
8#[derive(Debug, Deserialize, Serialize)]
9pub struct Nil;
10
11stateful!(Nil {});
12
13impl Action for Nil {
14    #[inline(always)]
15    fn stateful(
16        &self,
17        _io: &IoManager,
18        _res: &ResourceManager,
19        _config: &Config,
20        _sync_writer: &QWriter<SyncSignal>,
21        _async_writer: &QWriter<AsyncSignal>,
22    ) -> Result<Box<dyn StatefulAction>> {
23        Ok(Box::new(StatefulNil::new()))
24    }
25}
26
27impl Nil {
28    pub fn new() -> Self {
29        Self
30    }
31}
32
33impl Default for Nil {
34    fn default() -> Self {
35        Self
36    }
37}
38
39impl StatefulAction for StatefulNil {
40    impl_stateful!();
41
42    fn start(
43        &mut self,
44        sync_writer: &mut QWriter<SyncSignal>,
45        _async_writer: &mut QWriter<AsyncSignal>,
46        _state: &State,
47    ) -> Result<Signal> {
48        self.done = true;
49        sync_writer.push(SyncSignal::UpdateGraph);
50        Ok(Signal::none())
51    }
52}
53
54impl StatefulNil {
55    pub fn new() -> Self {
56        Self { done: false }
57    }
58}
59
60impl Default for StatefulNil {
61    fn default() -> Self {
62        Self::new()
63    }
64}