#[cfg(not(feature = "std"))]
use alloc::vec::Vec;
use super::{BACnetDeviceObjectPropertyReference, BACnetDeviceObjectReference};
use crate::enums::{
AccessAuthenticationFactorDisable, AccessRuleLocationSpecifier, AccessRuleTimeRangeSpecifier,
AuthenticationFactorType,
};
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct BACnetAccessRule {
pub time_range_specifier: AccessRuleTimeRangeSpecifier,
pub time_range: Option<BACnetDeviceObjectPropertyReference>,
pub location_specifier: AccessRuleLocationSpecifier,
pub location: Option<BACnetDeviceObjectReference>,
pub enable: bool,
}
impl BACnetAccessRule {
pub fn new(
time_range: Option<BACnetDeviceObjectPropertyReference>,
location: Option<BACnetDeviceObjectReference>,
enable: bool,
) -> Self {
Self {
time_range_specifier: if time_range.is_some() {
AccessRuleTimeRangeSpecifier::SPECIFIED
} else {
AccessRuleTimeRangeSpecifier::ALWAYS
},
time_range,
location_specifier: if location.is_some() {
AccessRuleLocationSpecifier::SPECIFIED
} else {
AccessRuleLocationSpecifier::ALL
},
location,
enable,
}
}
}
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct BACnetAssignedAccessRights {
pub assigned_access_rights: BACnetDeviceObjectReference,
pub enable: bool,
}
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct BACnetAuthenticationFactor {
pub format_type: AuthenticationFactorType,
pub format_class: u32,
pub value: Vec<u8>,
}
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub struct BACnetAuthenticationFactorFormat {
pub format_type: AuthenticationFactorType,
pub vendor_id: Option<u16>,
pub vendor_format: Option<u16>,
}
impl BACnetAuthenticationFactorFormat {
pub const fn standard(format_type: AuthenticationFactorType) -> Self {
Self {
format_type,
vendor_id: None,
vendor_format: None,
}
}
pub const fn custom(vendor_id: u16, vendor_format: u16) -> Self {
Self {
format_type: AuthenticationFactorType::CUSTOM,
vendor_id: Some(vendor_id),
vendor_format: Some(vendor_format),
}
}
}
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct BACnetCredentialAuthenticationFactor {
pub disable: AccessAuthenticationFactorDisable,
pub authentication_factor: BACnetAuthenticationFactor,
}
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct BACnetAuthenticationPolicyEntry {
pub credential_data_input: BACnetDeviceObjectReference,
pub index: u32,
}
#[derive(Debug, Clone, Default, PartialEq, Eq)]
pub struct BACnetAuthenticationPolicy {
pub policy: Vec<BACnetAuthenticationPolicyEntry>,
pub order_enforced: bool,
pub timeout: u32,
}