diff --git a/src/app/builder_protocol.rs b/src/app/builder_protocol.rs index 3e3296a0..19132f20 100644 --- a/src/app/builder_protocol.rs +++ b/src/app/builder_protocol.rs @@ -22,6 +22,11 @@ where /// The protocol defines hooks for connection setup, frame modification, and /// command completion. It is wrapped in an [`Arc`] and stored for later use /// by the connection actor. + /// + /// At present, the protocol must use `ProtocolError = ()`. This keeps the + /// protocol object safe for dynamic dispatch, maintains a uniform + /// interface across connections, and avoids leaking application-specific + /// error types into the builder API. #[must_use] pub fn with_protocol

(self, protocol: P) -> Self where diff --git a/src/fragment/tests.rs b/src/fragment/tests.rs index c0283c47..1338aff1 100644 --- a/src/fragment/tests.rs +++ b/src/fragment/tests.rs @@ -1,3 +1,9 @@ +//! Unit tests for the fragmentation and reassembly subsystem. +//! +//! Covers `FragmentHeader` field access, `FragmentSeries` ordering and +//! validation, `Fragmenter` splitting and message ID management, and +//! `Reassembler` assembly with size limits and expiry handling. + use std::{ num::NonZeroUsize, time::{Duration, Instant}, diff --git a/src/hooks.rs b/src/hooks.rs index 86581544..4b7f1381 100644 --- a/src/hooks.rs +++ b/src/hooks.rs @@ -19,10 +19,19 @@ use crate::{ pub struct ConnectionContext; /// Trait encapsulating protocol-specific logic and callbacks. +/// +/// `WireframeProtocol` allows a custom `ProtocolError` type, but +/// [`crate::app::WireframeApp::with_protocol`] currently requires +/// `ProtocolError = ()` so the protocol can be stored behind dynamic dispatch +/// with a uniform interface. This constraint may be relaxed in a future +/// release. pub trait WireframeProtocol: Send + Sync + 'static { /// Frame type written to the socket. type Frame: FrameLike; /// Custom error type for protocol operations. + /// + /// When installed via [`crate::app::WireframeApp::with_protocol`], this + /// must currently be `()`. type ProtocolError; /// Called once when a new connection is established. The provided @@ -45,10 +54,10 @@ pub trait WireframeProtocol: Send + Sync + 'static { /// /// impl WireframeProtocol for MyProtocol { /// type Frame = Vec; - /// type ProtocolError = String; + /// type ProtocolError = (); /// - /// fn handle_error(&self, error: Self::ProtocolError, _ctx: &mut ConnectionContext) { - /// tracing::error!(error = %error, "protocol error"); + /// fn handle_error(&self, _error: Self::ProtocolError, _ctx: &mut ConnectionContext) { + /// tracing::error!("protocol error"); /// // Custom handling here /// } /// } @@ -81,7 +90,7 @@ pub trait WireframeProtocol: Send + Sync + 'static { /// /// impl WireframeProtocol for MyProtocol { /// type Frame = Vec; - /// type ProtocolError = String; + /// type ProtocolError = (); /// /// fn on_eof(&self, error: &EofError, partial_data: &[u8], _ctx: &mut ConnectionContext) { /// match error {