Moved mqtt parse error to error.rs

This commit is contained in:
Dreaded_X 2023-04-24 02:46:02 +02:00
parent 0ad42c029e
commit 8f515ccf75
Signed by: Dreaded_X
GPG Key ID: FA5F485356B0D2D4
2 changed files with 11 additions and 9 deletions

View File

@ -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)]

View File

@ -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();