pub struct RegistrationDescriptor { /* private fields */ }Expand description
Registration descriptor sent to Home Assistant
This describes the device and its components (the sensors that are configured)
Implementations§
Source§impl RegistrationDescriptor
impl RegistrationDescriptor
Sourcepub fn new(name: &str) -> RegistrationDescriptor
pub fn new(name: &str) -> RegistrationDescriptor
Creates a new registration descriptor, with no sensor configured.
§Example
use mqtt_system_monitor::{ RegistrationDescriptor, Sensor };
let mut descriptor = RegistrationDescriptor::new("test_entity");
assert!(!descriptor.has_sensor(Sensor::CpuUsage));
descriptor.add_component(Sensor::CpuUsage);
assert!(descriptor.has_sensor(Sensor::CpuUsage));Sourcepub fn add_component(&mut self, sensor: Sensor)
pub fn add_component(&mut self, sensor: Sensor)
Adds a component to the descriptor
§Example
use mqtt_system_monitor::{ RegistrationDescriptor, Sensor };
let mut descriptor = RegistrationDescriptor::new("test_entity");
assert!(!descriptor.has_sensor(Sensor::CpuUsage));
descriptor.add_component(Sensor::CpuUsage);
assert!(descriptor.has_sensor(Sensor::CpuUsage));Sourcepub fn has_sensor(&self, sensor: Sensor) -> bool
pub fn has_sensor(&self, sensor: Sensor) -> bool
Returns true if the sensor is configured
Sourcepub fn remove_sensor(&mut self, sensor: Sensor)
pub fn remove_sensor(&mut self, sensor: Sensor)
Removes the sensor from this descriptor
Sourcepub fn discovery_topic(&self, prefix: &str) -> String
pub fn discovery_topic(&self, prefix: &str) -> String
Discovery topic for this sensor if individual updates are sent
Sourcepub fn state_topic(&self) -> &str
pub fn state_topic(&self) -> &str
Discovery topic for this sensor if individual updates are sent
Trait Implementations§
Source§impl Debug for RegistrationDescriptor
impl Debug for RegistrationDescriptor
Source§impl Display for RegistrationDescriptor
impl Display for RegistrationDescriptor
Auto Trait Implementations§
impl Freeze for RegistrationDescriptor
impl RefUnwindSafe for RegistrationDescriptor
impl Send for RegistrationDescriptor
impl Sync for RegistrationDescriptor
impl Unpin for RegistrationDescriptor
impl UnwindSafe for RegistrationDescriptor
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more