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            Self::Stubs {
35                update: setup.event_rx(i.update),
36                _phantom: std::marker::PhantomData,
37            },
38            Self::Hooks {
39                _phantom: std::marker::PhantomData,
40            },
41        )
42    }
43}
44
45impl<T> Clone for PropertyObserverHooks<T> {
46    fn clone(&self) -> Self {
47        Self {
48            _phantom: std::marker::PhantomData,
49        }
50    }
51}