std_modrpc/roles/
property_observer.rs

1#![allow(unused_variables)]
2
3use crate::interface::PropertyInterface;
4use crate::proto::{PropertyInitState, PropertyObserverConfig, PropertyUpdate};
5use modrpc::{EventRxBuilder, InterfaceRole, RoleSetup};
6
7pub struct PropertyObserverHooks<T> {
8    _phantom: std::marker::PhantomData<T>,
9}
10
11pub struct PropertyObserverStubs<T> {
12    pub update: EventRxBuilder<PropertyUpdate<T>>,
13    _phantom: std::marker::PhantomData<T>,
14}
15
16pub struct PropertyObserverRole<T> {
17    _phantom: std::marker::PhantomData<T>,
18}
19
20impl<T: mproto::Owned> InterfaceRole for PropertyObserverRole<T> {
21    type Interface = PropertyInterface<T>;
22    type Config = PropertyObserverConfig;
23    type Init = PropertyInitState<T>;
24    type Stubs = PropertyObserverStubs<T>;
25    type Hooks = PropertyObserverHooks<T>;
26
27    fn setup_worker(
28        i: &Self::Interface,
29        setup: &mut RoleSetup,
30        config: &Self::Config,
31        init: &Self::Init,
32    ) -> (Self::Stubs, Self::Hooks) {
33
34        (
35            Self::Stubs {
36                update: setup.event_rx(i.update),
37                _phantom: std::marker::PhantomData,
38            },
39            Self::Hooks {
40                _phantom: std::marker::PhantomData,
41            },
42        )
43    }
44}
45
46impl<T> Clone for PropertyObserverHooks<T> {
47    fn clone(&self) -> Self {
48        Self {
49            _phantom: std::marker::PhantomData,
50        }
51    }
52}