Remove thiserror from netfetch

This commit is contained in:
Dominik Werder
2025-02-19 15:46:08 +01:00
parent a827478bc7
commit 31538ee23a
11 changed files with 123 additions and 119 deletions

View File

@@ -1,8 +1,6 @@
use async_channel::Sender;
use bytes::Buf;
use dbpg::seriesbychannel::ChannelInfoQuery;
use err::thiserror;
use err::ThisError;
use log::*;
use netpod::ScalarType;
use netpod::SeriesKind;
@@ -17,15 +15,16 @@ use std::net::Ipv4Addr;
use std::time::SystemTime;
use taskrun::tokio::net::UdpSocket;
#[derive(Debug, ThisError)]
#[cstm(name = "NetfetchBeacons")]
pub enum Error {
Io(#[from] std::io::Error),
SeriesWriter(#[from] serieswriter::writer::Error),
ChannelSend,
ChannelRecv,
ChannelLookup(#[from] dbpg::seriesbychannel::Error),
}
autoerr::create_error_v1!(
name(Error, "NetfetchBeacons"),
enum variants {
Io(#[from] std::io::Error),
SeriesWriter(#[from] serieswriter::writer::Error),
ChannelSend,
ChannelRecv,
ChannelLookup(#[from] dbpg::seriesbychannel::Error),
},
);
impl<T> From<async_channel::SendError<T>> for Error {
fn from(_value: async_channel::SendError<T>) -> Self {

View File

@@ -3,8 +3,6 @@ use super::CreatedState;
use super::Ioid;
use ca_proto::ca::proto;
use dbpg::seriesbychannel::ChannelInfoQuery;
use err::thiserror;
use err::ThisError;
use log::*;
use proto::CaMsg;
use proto::ReadNotify;
@@ -12,11 +10,12 @@ use series::SeriesId;
use std::pin::Pin;
use std::time::Instant;
#[derive(Debug, ThisError)]
#[cstm(name = "NetfetchEnumfetch")]
pub enum Error {
MissingState,
}
autoerr::create_error_v1!(
name(Error, "NetfetchEnumfetch"),
enum variants {
MissingState,
},
);
pub trait ConnFuture: Send {
fn camsg(self: Pin<&mut Self>, camsg: CaMsg, conn: &mut CaConn) -> Result<(), Error>;

View File

@@ -1,8 +1,11 @@
use ca_proto::ca::proto;
#[derive(Debug, thiserror::Error)]
#[cstm(name = "ConnChannelError")]
pub enum Error {}
autoerr::create_error_v1!(
name(Error, "ConnChannelError"),
enum variants {
Logic,
},
);
trait Channel {
fn can_accept_ca_msg(&self) -> bool;

View File

@@ -14,12 +14,13 @@ use std::time::Duration;
use taskrun::tokio;
use tokio::task::JoinHandle;
#[derive(Debug, thiserror::Error)]
#[cstm(name = "IocSearch")]
pub enum Error {
LookupFailure(String),
IO(#[from] std::io::Error),
}
autoerr::create_error_v1!(
name(Error, "IocSearch"),
enum variants {
LookupFailure(String),
IO(#[from] std::io::Error),
},
);
async fn resolve_address(addr_str: &str) -> Result<SocketAddr, Error> {
const PORT_DEFAULT: u16 = 5064;