-
Notifications
You must be signed in to change notification settings - Fork 58
/
lib.rs
383 lines (322 loc) · 13.3 KB
/
lib.rs
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
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
#![allow(clippy::derive_partial_eq_without_eq)]
use b_2 as wsnt;
use t_1 as wstop;
use validate::Validate;
use ws_addr as wsa;
use xsd_types::types as xs;
use yaserde_derive::{YaDeserialize, YaSerialize};
#[derive(Default, PartialEq, Debug, YaSerialize, YaDeserialize)]
#[yaserde(
prefix = "tev",
namespace = "tev: http://www.onvif.org/ver10/events/wsdl"
)]
pub struct GetServiceCapabilities {}
impl Validate for GetServiceCapabilities {}
#[derive(Default, PartialEq, Debug, YaSerialize, YaDeserialize)]
#[yaserde(
prefix = "tev",
namespace = "tev: http://www.onvif.org/ver10/events/wsdl"
)]
pub struct GetServiceCapabilitiesResponse {
// The capabilities for the event service is returned in the Capabilities
// element.
#[yaserde(prefix = "tev", rename = "Capabilities")]
pub capabilities: Capabilities,
}
impl Validate for GetServiceCapabilitiesResponse {}
#[derive(Default, PartialEq, Debug, YaSerialize, YaDeserialize)]
#[yaserde(
prefix = "tev",
namespace = "tev: http://www.onvif.org/ver10/events/wsdl"
)]
pub struct Capabilities {
// Indicates that the WS Subscription policy is supported.
#[yaserde(attribute, rename = "WSSubscriptionPolicySupport")]
pub ws_subscription_policy_support: Option<bool>,
// Indicates that the WS Pull Point is supported.
#[yaserde(attribute, rename = "WSPullPointSupport")]
pub ws_pull_point_support: Option<bool>,
// Indicates that the WS Pausable Subscription Manager Interface is
// supported.
#[yaserde(attribute, rename = "WSPausableSubscriptionManagerInterfaceSupport")]
pub ws_pausable_subscription_manager_interface_support: Option<bool>,
// Maximum number of supported notification producers as defined by
// WS-BaseNotification.
#[yaserde(attribute, rename = "MaxNotificationProducers")]
pub max_notification_producers: Option<i32>,
// Maximum supported number of notification pull points.
#[yaserde(attribute, rename = "MaxPullPoints")]
pub max_pull_points: Option<i32>,
// Indication if the device supports persistent notification storage.
#[yaserde(attribute, rename = "PersistentNotificationStorage")]
pub persistent_notification_storage: Option<bool>,
}
impl Validate for Capabilities {}
// pub type Capabilities = Capabilities;
#[derive(Default, PartialEq, Debug, YaSerialize, YaDeserialize)]
#[yaserde(
prefix = "tev",
namespace = "tev: http://www.onvif.org/ver10/events/wsdl"
)]
pub struct CreatePullPointSubscription {
// Optional XPATH expression to select specific topics.
#[yaserde(prefix = "tev", rename = "Filter")]
pub filter: Option<wsnt::FilterType>,
// Initial termination time.
#[yaserde(prefix = "tev", rename = "InitialTerminationTime")]
pub initial_termination_time: Option<wsnt::AbsoluteOrRelativeTimeType>,
// Refer to
#[yaserde(prefix = "tev", rename = "SubscriptionPolicy")]
pub subscription_policy: Option<create_pull_point_subscription::SubscriptionPolicyType>,
}
impl Validate for CreatePullPointSubscription {}
pub mod create_pull_point_subscription {
use super::*;
#[derive(Default, PartialEq, Debug, YaSerialize, YaDeserialize)]
#[yaserde(
prefix = "tev",
namespace = "tev: http://www.onvif.org/ver10/events/wsdl"
)]
pub struct SubscriptionPolicyType {}
impl Validate for SubscriptionPolicyType {}
}
#[derive(Default, PartialEq, Debug, YaSerialize, YaDeserialize)]
#[yaserde(
prefix = "tev",
namespace = "tev: http://www.onvif.org/ver10/events/wsdl"
)]
pub struct CreatePullPointSubscriptionResponse {
// Endpoint reference of the subscription to be used for pulling the
// messages.
#[yaserde(prefix = "tev", rename = "SubscriptionReference")]
pub subscription_reference: wsa::EndpointReferenceType,
// Current time of the server for synchronization purposes.
#[yaserde(prefix = "wsnt", rename = "CurrentTime")]
pub current_time: wsnt::CurrentTime,
// Date time when the PullPoint will be shut down without further pull
// requests.
#[yaserde(prefix = "wsnt", rename = "TerminationTime")]
pub termination_time: wsnt::TerminationTime,
}
impl Validate for CreatePullPointSubscriptionResponse {}
#[derive(Default, PartialEq, Debug, YaSerialize, YaDeserialize)]
#[yaserde(
prefix = "tev",
namespace = "tev: http://www.onvif.org/ver10/events/wsdl"
)]
pub struct PullMessages {
// Maximum time to block until this method returns.
#[yaserde(prefix = "tev", rename = "Timeout")]
pub timeout: xs::Duration,
// Upper limit for the number of messages to return at once. A server
// implementation may decide to return less messages.
#[yaserde(prefix = "tev", rename = "MessageLimit")]
pub message_limit: i32,
}
impl Validate for PullMessages {}
#[derive(Default, PartialEq, Debug, YaSerialize, YaDeserialize)]
#[yaserde(
prefix = "tev",
namespace = "tev: http://www.onvif.org/ver10/events/wsdl"
)]
pub struct PullMessagesResponse {
// The date and time when the messages have been delivered by the web server
// to the client.
#[yaserde(prefix = "tev", rename = "CurrentTime")]
pub current_time: xs::DateTime,
// Date time when the PullPoint will be shut down without further pull
// requests.
#[yaserde(prefix = "tev", rename = "TerminationTime")]
pub termination_time: xs::DateTime,
// List of messages. This list shall be empty in case of a timeout.
#[yaserde(prefix = "wsnt", rename = "NotificationMessage")]
pub notification_message: Vec<wsnt::NotificationMessage>,
}
impl Validate for PullMessagesResponse {}
#[derive(Default, PartialEq, Debug, YaSerialize, YaDeserialize)]
#[yaserde(
prefix = "tev",
namespace = "tev: http://www.onvif.org/ver10/events/wsdl"
)]
pub struct PullMessagesFaultResponse {
// Maximum timeout supported by the device.
#[yaserde(prefix = "tev", rename = "MaxTimeout")]
pub max_timeout: xs::Duration,
// Maximum message limit supported by the device.
#[yaserde(prefix = "tev", rename = "MaxMessageLimit")]
pub max_message_limit: i32,
}
impl Validate for PullMessagesFaultResponse {}
#[derive(Default, PartialEq, Debug, YaSerialize, YaDeserialize)]
#[yaserde(
prefix = "tev",
namespace = "tev: http://www.onvif.org/ver10/events/wsdl"
)]
pub struct Seek {
// The date and time to match against stored messages.
#[yaserde(prefix = "tev", rename = "UtcTime")]
pub utc_time: xs::DateTime,
// Reverse the pull direction of PullMessages.
#[yaserde(prefix = "tev", rename = "Reverse")]
pub reverse: bool,
}
impl Validate for Seek {}
#[derive(Default, PartialEq, Debug, YaSerialize, YaDeserialize)]
#[yaserde(
prefix = "tev",
namespace = "tev: http://www.onvif.org/ver10/events/wsdl"
)]
pub struct SeekResponse {}
impl Validate for SeekResponse {}
#[derive(Default, PartialEq, Debug, YaSerialize, YaDeserialize)]
#[yaserde(
prefix = "tev",
namespace = "tev: http://www.onvif.org/ver10/events/wsdl"
)]
pub struct SetSynchronizationPoint {}
impl Validate for SetSynchronizationPoint {}
#[derive(Default, PartialEq, Debug, YaSerialize, YaDeserialize)]
#[yaserde(
prefix = "tev",
namespace = "tev: http://www.onvif.org/ver10/events/wsdl"
)]
pub struct SetSynchronizationPointResponse {}
impl Validate for SetSynchronizationPointResponse {}
#[derive(Default, PartialEq, Debug, YaSerialize, YaDeserialize)]
#[yaserde(
prefix = "tev",
namespace = "tev: http://www.onvif.org/ver10/events/wsdl"
)]
pub struct GetEventProperties {}
impl Validate for GetEventProperties {}
#[derive(Default, PartialEq, Debug, YaSerialize, YaDeserialize)]
#[yaserde(
prefix = "tev",
namespace = "tev: http://www.onvif.org/ver10/events/wsdl"
)]
pub struct GetEventPropertiesResponse {
// List of topic namespaces supported.
#[yaserde(prefix = "tev", rename = "TopicNamespaceLocation")]
pub topic_namespace_location: Vec<String>,
// True when topicset is fixed for all times.
#[yaserde(prefix = "wsnt", rename = "FixedTopicSet")]
pub fixed_topic_set: wsnt::FixedTopicSet,
// Set of topics supported.
#[yaserde(prefix = "wstop", rename = "TopicSet")]
pub topic_set: wstop::TopicSet,
// Defines the XPath expression syntax supported for matching topic
// expressions.
#[yaserde(prefix = "wsnt", rename = "TopicExpressionDialect")]
pub topic_expression_dialect: Vec<wsnt::TopicExpressionDialect>,
// Defines the XPath function set supported for message content filtering.
#[yaserde(prefix = "tev", rename = "MessageContentFilterDialect")]
pub message_content_filter_dialect: Vec<String>,
// Optional ProducerPropertiesDialects. Refer to
#[yaserde(prefix = "tev", rename = "ProducerPropertiesFilterDialect")]
pub producer_properties_filter_dialect: Vec<String>,
// The Message Content Description Language allows referencing
// of vendor-specific types. In order to ease the integration of such types
// into a client application,
// the GetEventPropertiesResponse shall list all URI locations to schema
// files whose types are
// used in the description of notifications, with
// MessageContentSchemaLocation elements.
#[yaserde(prefix = "tev", rename = "MessageContentSchemaLocation")]
pub message_content_schema_location: Vec<String>,
}
impl Validate for GetEventPropertiesResponse {}
// When this element is included in the SubscriptionPolicy, the pullpoint shall
// not provide Initialized or Deleted events for Properties.
#[derive(Default, PartialEq, Debug, YaSerialize, YaDeserialize)]
#[yaserde(
prefix = "tev",
namespace = "tev: http://www.onvif.org/ver10/events/wsdl"
)]
pub struct ChangedOnly {}
impl Validate for ChangedOnly {}
// Returns the capabilities of the event service. The result is returned in a
// typed answer.
pub async fn get_service_capabilities<T: transport::Transport>(
transport: &T,
request: &GetServiceCapabilities,
) -> Result<GetServiceCapabilitiesResponse, transport::Error> {
transport::request(transport, request).await
}
// This method returns a PullPointSubscription that can be polled using
// PullMessages.
// This message contains the same elements as the SubscriptionRequest of the
// WS-BaseNotification without the ConsumerReference.
pub async fn create_pull_point_subscription<T: transport::Transport>(
transport: &T,
request: &CreatePullPointSubscription,
) -> Result<CreatePullPointSubscriptionResponse, transport::Error> {
transport::request(transport, request).await
}
// The WS-BaseNotification specification defines a set of OPTIONAL
// WS-ResouceProperties.
// This specification does not require the implementation of the
// WS-ResourceProperty interface.
// Instead, the subsequent direct interface shall be implemented by an ONVIF
// compliant device
// in order to provide information about the FilterDialects, Schema files and
// topics supported by
// the device.
pub async fn get_event_properties<T: transport::Transport>(
transport: &T,
request: &GetEventProperties,
) -> Result<GetEventPropertiesResponse, transport::Error> {
transport::request(transport, request).await
}
// This method pulls one or more messages from a PullPoint.
// The device shall provide the following PullMessages command for all
// SubscriptionManager
// endpoints returned by the CreatePullPointSubscription command. This method
// shall not wait until
// the requested number of messages is available but return as soon as at least
// one message is available.
pub async fn pull_messages<T: transport::Transport>(
transport: &T,
request: &PullMessages,
) -> Result<PullMessagesResponse, transport::Error> {
transport::request(transport, request).await
}
// This method readjusts the pull pointer into the past.
// A device supporting persistent notification storage shall provide the
// following Seek command for all SubscriptionManager endpoints returned by
// the CreatePullPointSubscription command. The optional Reverse argument can
// be used to reverse the pull direction of the PullMessages command.
pub async fn seek<T: transport::Transport>(
transport: &T,
request: &Seek,
) -> Result<SeekResponse, transport::Error> {
transport::request(transport, request).await
}
// Properties inform a client about property creation, changes and
// deletion in a uniform way. When a client wants to synchronize its properties
// with the
// properties of the device, it can request a synchronization point which
// repeats the current
// status of all properties to which a client has subscribed. The
// PropertyOperation of all
// produced notifications is set to “Initialized”. The Synchronization Point
// is
// requested directly from the SubscriptionManager which was returned in either
// the
// SubscriptionResponse or in the CreatePullPointSubscriptionResponse. The
// property update is
// transmitted via the notification transportation of the notification
// interface. This method is mandatory.
pub async fn set_synchronization_point<T: transport::Transport>(
transport: &T,
request: &SetSynchronizationPoint,
) -> Result<SetSynchronizationPointResponse, transport::Error> {
transport::request(transport, request).await
}
// The device shall provide the following Unsubscribe command for all
// SubscriptionManager endpoints returned by the CreatePullPointSubscription
// command.
// pub async fn unsubscribe<T: transport::Transport>(
// transport: &T
// ) -> Result<, transport::Error> {
// transport::request(transport, request).await
// }