feat: xserial-client with session management, mlua integration, and 238 tests

- Session: background I/O task with SessionHandle for send/read/close/reconfigure
- SessionManager: multi-session collection with aggregated event broadcast
- Config: serializable SessionConfig/PipelineConfig/FramerConfig/DecoderConfig
- Lua: xserial global (open/list_ports/sleep/log) + session userdata API
- RingBuffer: bounded history buffer with pipeline filtering
- Core: added Serialize/Deserialize+Default to Endian/TextEncoding/PlotFormat
- Core: added Send bound to Framer trait for tokio task compatibility
- 238 tests (193 core + 10 config + 7 Lua + 9 session + 18 pipeline + 1 doctest)
This commit is contained in:
2026-06-08 00:25:59 +08:00
parent 60c60a8044
commit 530986d068
19 changed files with 1494 additions and 16 deletions

View File

@@ -13,7 +13,7 @@ pub use crate::protocol::Endian;
/// arrived.
///
/// [`feed`]: Framer::feed
pub trait Framer {
pub trait Framer: Send {
/// Feed a chunk of newly arrived bytes.
///
/// Any complete frames that can be extracted are returned. The

View File

@@ -2,10 +2,13 @@ pub mod text;
pub mod hex;
pub mod plot;
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
use serde::{Deserialize, Serialize};
#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize, Default)]
pub enum Endian {
Little,
#[default]
Big,
Little,
}
/// Decoded result from a protocol decoder.

View File

@@ -1,8 +1,9 @@
use super::{DecodedData, ProtocolDecoder};
use crate::protocol::Endian;
use serde::{Deserialize, Serialize};
/// Numeric type of samples in a plot frame.
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
pub enum SampleType {
I8,
U8,
@@ -43,13 +44,11 @@ impl SampleType {
}
/// Channel layout for multi-channel plot data.
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize, Default)]
pub enum PlotFormat {
/// Interleaved: ch0_s0, ch1_s0, ch0_s1, ch1_s1, ...
#[default]
Interleaved,
/// Block: ch0_s0, ch0_s1, ..., ch1_s0, ch1_s1, ...
Block,
/// XY pairs: x0, y0, x1, y1, ... (equivalent to 2 interleaved channels).
XY,
}

View File

@@ -1,14 +1,13 @@
use super::{DecodedData, ProtocolDecoder};
/// Supported text encodings for the text protocol decoder.
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
use serde::{Deserialize, Serialize};
#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize, Default)]
pub enum TextEncoding {
/// Standard UTF-8. Returns `None` from `decode()` on invalid byte sequences.
#[default]
Utf8,
/// ISO-8859-1 / Latin-1. Every byte maps 1:1 to a Unicode code point.
/// This encoding never fails.
Latin1,
/// 7-bit ASCII. Returns `None` from `decode()` if any byte has the high bit set.
Ascii,
}