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