Moved mqtt parse error to error.rs
This commit is contained in:
parent
0ad42c029e
commit
8f515ccf75
|
@ -1,6 +1,7 @@
|
|||
use std::{error, fmt, result};
|
||||
|
||||
use axum::{http::status::InvalidStatusCode, response::IntoResponse};
|
||||
use bytes::Bytes;
|
||||
use rumqttc::ClientError;
|
||||
use serde::{Deserialize, Serialize};
|
||||
use thiserror::Error;
|
||||
|
@ -57,6 +58,12 @@ impl fmt::Display for MissingEnv {
|
|||
|
||||
impl error::Error for MissingEnv {}
|
||||
|
||||
#[derive(Debug, Error)]
|
||||
pub enum ParseError {
|
||||
#[error("Invalid message payload received: {0:?}")]
|
||||
InvalidPayload(Bytes),
|
||||
}
|
||||
|
||||
#[derive(Debug, Error)]
|
||||
pub enum ConfigParseError {
|
||||
#[error(transparent)]
|
||||
|
|
13
src/mqtt.rs
13
src/mqtt.rs
|
@ -1,19 +1,14 @@
|
|||
use std::time::{SystemTime, UNIX_EPOCH};
|
||||
|
||||
use bytes::Bytes;
|
||||
use serde::{Deserialize, Serialize};
|
||||
use thiserror::Error;
|
||||
use tracing::{debug, warn};
|
||||
|
||||
use rumqttc::{Event, EventLoop, Incoming, Publish};
|
||||
|
||||
use crate::event::{self, EventChannel};
|
||||
|
||||
#[derive(Debug, Error)]
|
||||
pub enum ParseError {
|
||||
#[error("Invalid message payload received: {0:?}")]
|
||||
InvalidPayload(Bytes),
|
||||
}
|
||||
use crate::{
|
||||
error::ParseError,
|
||||
event::{self, EventChannel},
|
||||
};
|
||||
|
||||
pub fn start(mut eventloop: EventLoop, event_channel: &EventChannel) {
|
||||
let tx = event_channel.get_tx();
|
||||
|
|
Loading…
Reference in New Issue
Block a user