pub trait MqttEnergyPort: Send + Sync {
// Required methods
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 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 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 is_running<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = bool> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait;
}Expand description
Port (trait) définissant le contrat pour la couche MQTT.
Le domaine ne connaît pas rumqttc — seul ce trait existe dans l’application layer.
L’adapter MqttEnergyAdapter dans infrastructure/mqtt/ implémente ce trait.
Flux: capteur → Home Assistant → Mosquitto (TLS:8883) → MqttEnergyAdapter → on_reading_received() → RegisterEnergyReadingFromIoTUseCase → DB
Topic pattern: koprogo/{copropriete_id}/energy/{unit_id}/{metric}
Required Methods§
Sourcefn 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.
Sourcefn 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.
Sourcefn 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}