extract api-types crate, adopt thiserror for all errors

api-types: standalone crate with DTOs (widget, data source, layout, preset)
extracted from http-api. Shared between http-api and future SPA.

thiserror: replaced all manual Display impls with derive macros across
8 crates (config-sqlite, config-memory, tcp-server, tcp-client,
http-json, rss, media, application).
This commit is contained in:
2026-06-18 23:01:31 +02:00
parent 6e77236936
commit af47e3939c
30 changed files with 79 additions and 98 deletions

View File

@@ -4,23 +4,16 @@ use std::time::Duration;
use client_domain::NetworkPort;
use protocol::MAX_FRAME_SIZE;
#[derive(Debug)]
#[derive(Debug, thiserror::Error)]
pub enum TcpClientError {
Io(std::io::Error),
#[error("io: {0}")]
Io(#[from] std::io::Error),
#[error("not connected")]
NotConnected,
#[error("frame too large: {0}")]
FrameTooLarge(usize),
}
impl std::fmt::Display for TcpClientError {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
match self {
TcpClientError::Io(e) => write!(f, "io: {e}"),
TcpClientError::NotConnected => write!(f, "not connected"),
TcpClientError::FrameTooLarge(n) => write!(f, "frame too large: {n}"),
}
}
}
pub struct StdTcpClient {
stream: Option<TcpStream>,
}