Extract serde helper crate

This commit is contained in:
Dominik Werder
2025-04-29 12:16:53 +02:00
parent 265f4b9bd9
commit b4a3dbbcb5
8 changed files with 17 additions and 59 deletions

View File

@@ -2,13 +2,10 @@
name = "ingest-linux"
version = "0.0.1"
authors = ["Dominik Werder <dominik.werder@gmail.com>"]
edition = "2021"
edition = "2024"
[dependencies]
libc = "0.2"
thiserror = "=0.0.1"
autoerr = "0.0.3"
log = { path = "../log" }
taskrun = { path = "../../daqbuffer/crates/taskrun" }
[patch.crates-io]
thiserror = { git = "https://github.com/dominikwerder/thiserror.git", branch = "cstm" }

View File

@@ -1,14 +1,14 @@
use std::ffi::CStr;
use taskrun::tokio;
use thiserror::Error;
use tokio::net::TcpStream;
#[derive(Debug, Error)]
#[error("{self}")]
pub enum Error {
SocketOptionSet,
SocketOptionGet,
}
autoerr::create_error_v1!(
name(Error, "LinuxNetError"),
enum variants {
SocketOptionSet,
SocketOptionGet,
},
);
pub fn local_hostname() -> String {
let mut buf = vec![0u8; 128];

View File

@@ -1,13 +1,13 @@
use std::ffi::CStr;
use std::mem::MaybeUninit;
use thiserror::Error;
#[derive(Debug, Error)]
#[cstm(name = "LinuxSignal")]
pub enum Error {
SignalHandlerSet,
SignalHandlerUnset,
}
autoerr::create_error_v1!(
name(Error, "LinuxSignalError"),
enum variants {
SignalHandlerSet,
SignalHandlerUnset,
},
);
pub fn set_signal_handler(
signum: libc::c_int,

View File

@@ -44,7 +44,6 @@ serieswriter = { path = "../serieswriter" }
stats = { path = "../stats" }
scywr = { path = "../scywr" }
dbpg = { path = "../dbpg" }
serde_helper = { path = "../serde_helper" }
ingest-linux = { path = "../ingest-linux" }
err = { path = "../../daqbuf-err", package = "daqbuf-err" }
netpod = { path = "../../daqbuf-netpod", package = "daqbuf-netpod" }
@@ -53,12 +52,10 @@ items_2 = { path = "../../daqbuf-items-2", package = "daqbuf-items-2" }
streams = { path = "../../daqbuf-streams", package = "daqbuf-streams" }
ca_proto = { path = "../../daqbuf-ca-proto", package = "daqbuf-ca-proto" }
ca-proto-tokio = { path = "../../daqbuf-ca-proto-tokio", package = "daqbuf-ca-proto-tokio" }
serde-helper = { path = "../../daqbuf-serde-helper", package = "daqbuf-serde-helper" }
taskrun = { path = "../../daqbuffer/crates/taskrun" }
mrucache = { path = "../mrucache" }
batchtools = { path = "../batchtools" }
[patch.crates-io]
thiserror = { git = "https://github.com/dominikwerder/thiserror.git", branch = "cstm" }
[features]
disabled = []

View File

@@ -1,8 +0,0 @@
[package]
name = "serde_helper"
version = "0.0.1"
authors = ["Dominik Werder <dominik.werder@gmail.com>"]
edition = "2021"
[dependencies]
serde = { version = "1.0", features = ["derive"] }

View File

@@ -1,2 +0,0 @@
pub mod serde_dummy;
pub mod serde_instant;

View File

@@ -1,12 +0,0 @@
#[allow(non_snake_case)]
pub mod serde_dummy {
use serde::Serializer;
#[allow(unused)]
pub fn serialize<S, T>(val: &T, ser: S) -> Result<S::Ok, S::Error>
where
S: Serializer,
{
ser.serialize_str("DUMMY")
}
}

View File

@@ -1,14 +0,0 @@
#[allow(non_snake_case)]
pub mod serde_Instant_elapsed_ms {
use serde::Serializer;
use std::time::Instant;
#[allow(unused)]
pub fn serialize<S>(val: &Instant, ser: S) -> Result<S::Ok, S::Error>
where
S: Serializer,
{
let dur = val.elapsed();
ser.serialize_u64(dur.as_secs() * 1000 + dur.subsec_millis() as u64)
}
}