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
// THIS FILE IS AUTO-GENERATED

use crate::{
    service::{HapService, Service},
    characteristic::{
        HapCharacteristic,
		lock_control_point,
		version,
		logs,
		audio_feedback,
		lock_management_auto_security_timeout,
		administrator_only_access,
		lock_last_known_action,
		current_door_state,
		motion_detected,
		name,
	},
    HapType,
};

/// Lock Management Service.
pub type LockManagement = Service<LockManagementInner>;

impl Default for LockManagement {
    fn default() -> LockManagement { new() }
}

/// Inner type of the Lock Management Service.
#[derive(Default)]
pub struct LockManagementInner {
    /// ID of the Lock Management Service.
    id: u64,
    /// `HapType` of the Lock Management Service.
    hap_type: HapType,
    /// Specifies if the Service is hidden.
    hidden: bool,
    /// Specifies if the Service is the primary Service of the Accessory.
    primary: bool,

	/// Lock Control Point Characteristic.
	pub lock_control_point: lock_control_point::LockControlPoint,
	/// Version Characteristic.
	pub version: version::Version,

	/// Logs Characteristic.
	pub logs: Option<logs::Logs>,
	/// Audio Feedback Characteristic.
	pub audio_feedback: Option<audio_feedback::AudioFeedback>,
	/// Lock Management Auto Security Timeout Characteristic.
	pub lock_management_auto_security_timeout: Option<lock_management_auto_security_timeout::LockManagementAutoSecurityTimeout>,
	/// Administrator Only Access Characteristic.
	pub administrator_only_access: Option<administrator_only_access::AdministratorOnlyAccess>,
	/// Lock Last Known Action Characteristic.
	pub lock_last_known_action: Option<lock_last_known_action::LockLastKnownAction>,
	/// Current Door State Characteristic.
	pub current_door_state: Option<current_door_state::CurrentDoorState>,
	/// Motion Detected Characteristic.
	pub motion_detected: Option<motion_detected::MotionDetected>,
	/// Name Characteristic.
	pub name: Option<name::Name>,
}

impl HapService for LockManagementInner {
    fn get_id(&self) -> u64 {
        self.id
    }

    fn set_id(&mut self, id: u64) {
        self.id = id;
    }

    fn get_type(&self) -> HapType {
        self.hap_type
    }

    fn get_hidden(&self) -> bool {
        self.hidden
    }

    fn set_hidden(&mut self, hidden: bool) {
        self.hidden = hidden;
    }

    fn get_primary(&self) -> bool {
        self.primary
    }

    fn set_primary(&mut self, primary: bool) {
        self.primary = primary;
    }

    fn get_characteristics(&self) -> Vec<&dyn HapCharacteristic> {
        let mut characteristics: Vec<&dyn HapCharacteristic> = vec![
			&self.lock_control_point,
			&self.version,
		];
		if let Some(c) = &self.logs {
		    characteristics.push(c);
		}
		if let Some(c) = &self.audio_feedback {
		    characteristics.push(c);
		}
		if let Some(c) = &self.lock_management_auto_security_timeout {
		    characteristics.push(c);
		}
		if let Some(c) = &self.administrator_only_access {
		    characteristics.push(c);
		}
		if let Some(c) = &self.lock_last_known_action {
		    characteristics.push(c);
		}
		if let Some(c) = &self.current_door_state {
		    characteristics.push(c);
		}
		if let Some(c) = &self.motion_detected {
		    characteristics.push(c);
		}
		if let Some(c) = &self.name {
		    characteristics.push(c);
		}
		characteristics
    }

    fn get_mut_characteristics(&mut self) -> Vec<&mut dyn HapCharacteristic> {
        let mut characteristics: Vec<&mut dyn HapCharacteristic> = vec![
			&mut self.lock_control_point,
			&mut self.version,
		];
		if let Some(c) = &mut self.logs {
		    characteristics.push(c);
		}
		if let Some(c) = &mut self.audio_feedback {
		    characteristics.push(c);
		}
		if let Some(c) = &mut self.lock_management_auto_security_timeout {
		    characteristics.push(c);
		}
		if let Some(c) = &mut self.administrator_only_access {
		    characteristics.push(c);
		}
		if let Some(c) = &mut self.lock_last_known_action {
		    characteristics.push(c);
		}
		if let Some(c) = &mut self.current_door_state {
		    characteristics.push(c);
		}
		if let Some(c) = &mut self.motion_detected {
		    characteristics.push(c);
		}
		if let Some(c) = &mut self.name {
		    characteristics.push(c);
		}
		characteristics
    }
}

/// Creates a new Lock Management Service.
pub fn new() -> LockManagement {
    LockManagement::new(LockManagementInner {
        hap_type: HapType::LockManagement,
		lock_control_point: lock_control_point::new(),
		version: version::new(),
		..Default::default()
    })
}