pub struct MqttEnergyAdapter { /* private fields */ }Expand description
Adapter MQTT: subscribe aux topics Home Assistant → dispatch vers IoTRepository.
Flux: Mosquitto broker → rumqttc EventLoop (tokio::spawn) → parse topic (copropriete_id + unit_id) + deserialize JSON payload → IoTReading::new() (validation domaine) → iot_repo.create_reading()
Implementations§
Source§impl MqttEnergyAdapter
impl MqttEnergyAdapter
pub fn new(config: MqttConfig, iot_repo: Arc<dyn IoTRepository>) -> Self
Trait Implementations§
Source§impl MqttEnergyPort for MqttEnergyAdapter
impl MqttEnergyPort for MqttEnergyAdapter
Source§fn start_listening<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<(), MqttError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn start_listening<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<(), MqttError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Démarre l’écoute MQTT (connect + subscribe).
Non-bloquant : lance un tokio::spawn en interne.
Source§fn stop_listening<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<(), MqttError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn stop_listening<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<(), MqttError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Arrête proprement l’écoute MQTT.
Source§fn publish_alert<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
_copropriete_id: Uuid,
alert_type: &'life1 str,
_payload: &'life2 str,
) -> Pin<Box<dyn Future<Output = Result<(), MqttError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
fn publish_alert<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
_copropriete_id: Uuid,
alert_type: &'life1 str,
_payload: &'life2 str,
) -> Pin<Box<dyn Future<Output = Result<(), MqttError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Publie un message sortant (ex: alerte anomalie → Home Assistant).
Topic: koprogo/{copropriete_id}/alerts/{alert_type}
Auto Trait Implementations§
impl Freeze for MqttEnergyAdapter
impl !RefUnwindSafe for MqttEnergyAdapter
impl Send for MqttEnergyAdapter
impl Sync for MqttEnergyAdapter
impl Unpin for MqttEnergyAdapter
impl UnsafeUnpin for MqttEnergyAdapter
impl !UnwindSafe for MqttEnergyAdapter
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
§impl<T> Fake for T
impl<T> Fake for T
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreCreates a shared type from an unshared type.