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