onvif_server/traits/
device.rs1use crate::error::{not_implemented, OnvifError};
2use crate::generated::types::{
3 DeviceInfo, HostnameInformation, NetworkInterface, Scope, ScopeDefinition,
4};
5use async_trait::async_trait;
6
7#[async_trait]
16pub trait DeviceService: Send + Sync + 'static {
17 async fn get_system_date_and_time(&self) -> Result<chrono::DateTime<chrono::Utc>, OnvifError> {
19 Ok(chrono::Utc::now())
20 }
21
22 async fn get_device_information(&self) -> Result<DeviceInfo, OnvifError> {
24 not_implemented()
25 }
26
27 async fn get_scopes(&self) -> Result<Vec<Scope>, OnvifError> {
29 Ok(vec![
30 Scope {
31 scope_def: ScopeDefinition::Fixed,
32 scope_item: "onvif://www.onvif.org/type/video_encoder".into(),
33 },
34 Scope {
35 scope_def: ScopeDefinition::Fixed,
36 scope_item: "onvif://www.onvif.org/Profile/Streaming".into(),
37 },
38 ])
39 }
40
41 async fn get_hostname(&self) -> Result<HostnameInformation, OnvifError> {
43 Ok(HostnameInformation {
44 from_dhcp: false,
45 name: Some("onvif-device".into()),
46 })
47 }
48
49 async fn get_network_interfaces(&self) -> Result<Vec<NetworkInterface>, OnvifError> {
51 not_implemented()
52 }
53}