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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
mod multiple_packet;
use super::*;
use crate::epath::EPath;
pub use multiple_packet::MultipleServicePacket;
use rseip_core::codec::{Decode, Encode, SliceContainer};
#[async_trait::async_trait]
pub trait CommonServices: MessageService {
#[inline]
async fn get_attribute_all<'de, R>(&mut self, path: EPath) -> Result<R, Self::Error>
where
R: Decode<'de> + 'static,
{
send_and_extract(self, 0x01, path, ()).await
}
#[inline]
async fn set_attribute_all<D: Encode + Send + Sync>(
&mut self,
path: EPath,
attrs: D,
) -> Result<(), Self::Error> {
send_and_extract(self, 0x02, path, attrs).await
}
#[inline]
async fn get_attribute_list<'de, R>(
&mut self,
path: EPath,
attrs: &[u16],
) -> Result<R, Self::Error>
where
R: Decode<'de> + 'static,
{
let attrs_len = attrs.len();
debug_assert!(attrs_len <= u16::MAX as usize);
send_and_extract(
self,
0x03,
path,
(
attrs_len as u16,
SliceContainer::new(attrs).with_bytes_count(2 * attrs_len),
),
)
.await
}
#[inline]
async fn set_attribute_list<'de, D, R>(
&mut self,
path: EPath,
attrs: D,
) -> Result<R, Self::Error>
where
D: Encode + Send + Sync,
R: Decode<'de> + 'static,
{
send_and_extract(self, 0x04, path, attrs).await
}
#[inline]
async fn reset(&mut self, path: EPath) -> Result<(), Self::Error> {
send_and_extract(self, 0x05, path, ()).await
}
#[inline]
async fn start(&mut self, path: EPath) -> Result<(), Self::Error> {
send_and_extract(self, 0x06, path, ()).await
}
#[inline]
async fn stop(&mut self, path: EPath) -> Result<(), Self::Error> {
send_and_extract(self, 0x07, path, ()).await
}
#[inline]
async fn create<'de, D, R>(&mut self, path: EPath, data: D) -> Result<R, Self::Error>
where
D: Encode + Send + Sync,
R: Decode<'de> + 'static,
{
send_and_extract(self, 0x08, path, data).await
}
#[inline]
async fn delete(&mut self, path: EPath) -> Result<(), Self::Error> {
send_and_extract(self, 0x09, path, ()).await
}
#[inline]
async fn apply_attributes<'de, D, R>(&mut self, path: EPath, data: D) -> Result<R, Self::Error>
where
D: Encode + Send + Sync,
R: Decode<'de> + 'static,
{
send_and_extract(self, 0x0D, path, data).await
}
#[inline]
async fn get_attribute_single<'de, R>(&mut self, path: EPath) -> Result<R, Self::Error>
where
R: Decode<'de> + 'static,
{
send_and_extract(self, 0x0E, path, ()).await
}
#[inline]
async fn set_attribute_single<D: Encode + Send + Sync>(
&mut self,
path: EPath,
data: D,
) -> Result<(), Self::Error> {
send_and_extract(self, 0x10, path, data).await
}
#[inline]
async fn restore(&mut self, path: EPath) -> Result<(), Self::Error> {
send_and_extract(self, 0x15, path, ()).await
}
#[inline]
async fn save(&mut self, path: EPath) -> Result<(), Self::Error> {
send_and_extract(self, 0x16, path, ()).await
}
#[inline]
async fn no_operation(&mut self, path: EPath) -> Result<(), Self::Error> {
send_and_extract(self, 0x17, path, ()).await
}
#[inline]
async fn get_member<'de, R: Decode<'de> + 'static>(
&mut self,
path: EPath,
) -> Result<R, Self::Error> {
send_and_extract(self, 0x18, path, ()).await
}
#[inline]
async fn set_member<'de, D, R>(&mut self, path: EPath, data: D) -> Result<R, Self::Error>
where
D: Encode + Send + Sync,
R: Decode<'de> + 'static,
{
send_and_extract(self, 0x19, path, data).await
}
#[inline]
async fn insert_member<'de, D, R>(&mut self, path: EPath, data: D) -> Result<R, Self::Error>
where
D: Encode + Send + Sync,
R: Decode<'de> + 'static,
{
send_and_extract(self, 0x1A, path, data).await
}
#[inline]
async fn remove_member(&mut self, path: EPath) -> Result<(), Self::Error> {
send_and_extract(self, 0x1B, path, ()).await
}
#[inline]
async fn group_sync(&mut self, path: EPath) -> Result<(), Self::Error> {
send_and_extract(self, 0x1C, path, ()).await
}
#[inline]
fn multiple_service<P, D>(&mut self) -> MultipleServicePacket<'_, Self, P, D>
where
Self: Sized,
P: Encode,
D: Encode,
{
MultipleServicePacket::new(self)
}
}
#[async_trait::async_trait]
impl<T: MessageService> CommonServices for T {}