diff --git a/src/app.rs b/src/app.rs index 3776271b..90041e77 100644 --- a/src/app.rs +++ b/src/app.rs @@ -1,3 +1,9 @@ +//! Application builder configuring routes and middleware. +//! +//! `WireframeApp` stores registered routes, services, and middleware +//! for a [`WireframeServer`]. Methods return [`Result`] so callers +//! can chain registrations ergonomically. + use std::{boxed::Box, collections::HashMap, future::Future, pin::Pin}; /// Configures routing and middleware for a `WireframeServer`. diff --git a/src/extractor.rs b/src/extractor.rs index f3b0af39..d5e2ae9f 100644 --- a/src/extractor.rs +++ b/src/extractor.rs @@ -1,3 +1,9 @@ +//! Request context types and extractor traits. +//! +//! The `MessageRequest` struct carries connection metadata and shared +//! application state. Implement [`FromMessageRequest`] to extract data +//! for handlers. + use std::{net::SocketAddr, sync::Arc}; /// Request context passed to extractors. diff --git a/src/frame.rs b/src/frame.rs index c15c3a66..c2ca7492 100644 --- a/src/frame.rs +++ b/src/frame.rs @@ -1,3 +1,9 @@ +//! Frame encoding and decoding traits. +//! +//! A `FrameProcessor` converts raw bytes into logical frames and back. +//! Implementations may use any framing strategy suitable for the +//! underlying transport. + use async_trait::async_trait; use bytes::BytesMut; diff --git a/src/lib.rs b/src/lib.rs index d9acc4e3..e763b16b 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1,3 +1,9 @@ +#![doc(html_root_url = "https://docs.rs/wireframe/latest")] +//! Public API for the `wireframe` library. +//! +//! This crate provides building blocks for asynchronous binary protocol +//! servers, including routing, middleware, and connection utilities. + pub mod app; pub mod extractor; pub mod frame; diff --git a/src/main.rs b/src/main.rs index de72fc02..c21b86c0 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,3 +1,7 @@ +//! Minimal binary demonstrating `wireframe` usage. +//! +//! Currently prints a greeting and exits. + fn main() { println!("Hello from Wireframe!"); } diff --git a/src/message.rs b/src/message.rs index 6d44e918..d2acc1dc 100644 --- a/src/message.rs +++ b/src/message.rs @@ -1,3 +1,8 @@ +//! Message trait and serialization helpers. +//! +//! Types implementing [`Message`] can be encoded and decoded using +//! `bincode` with standard configuration. + use bincode::{ BorrowDecode, Encode, diff --git a/src/middleware.rs b/src/middleware.rs index d857e3c6..927648c0 100644 --- a/src/middleware.rs +++ b/src/middleware.rs @@ -1,3 +1,8 @@ +//! Traits and helpers for request middleware. +//! +//! Middleware components implement [`Transform`] to wrap services and +//! process `ServiceRequest` instances before passing them along the chain. + use async_trait::async_trait; /// Incoming request wrapper passed through middleware. diff --git a/src/preamble.rs b/src/preamble.rs index bc71aa52..4f2bda14 100644 --- a/src/preamble.rs +++ b/src/preamble.rs @@ -1,3 +1,8 @@ +//! Connection preamble decoding utilities. +//! +//! The optional preamble is read before processing a connection, and this +//! module provides helpers to decode it using `bincode`. + use bincode::{BorrowDecode, borrow_decode_from_slice, config, error::DecodeError}; use tokio::io::{self, AsyncRead, AsyncReadExt}; diff --git a/src/rewind_stream.rs b/src/rewind_stream.rs index 88ac90e9..d40f4791 100644 --- a/src/rewind_stream.rs +++ b/src/rewind_stream.rs @@ -1,3 +1,8 @@ +//! Async stream adapter that replays leftover bytes. +//! +//! `RewindStream` emits any bytes buffered from a preamble read before +//! delegating reads and writes to the underlying stream. + use std::{ io, pin::Pin, diff --git a/src/server.rs b/src/server.rs index d294b27e..c5b5bc00 100644 --- a/src/server.rs +++ b/src/server.rs @@ -1,3 +1,9 @@ +//! Tokio-based server for `WireframeApp` instances. +//! +//! `WireframeServer` spawns worker tasks to accept TCP connections, +//! optionally decoding a connection preamble before handing the +//! stream to the application. + use std::io; #[cfg(not(debug_assertions))] diff --git a/tests/preamble.rs b/tests/preamble.rs index ecb1fd4d..0b090e09 100644 --- a/tests/preamble.rs +++ b/tests/preamble.rs @@ -1,3 +1,5 @@ +//! Tests for connection preamble reading. + use bincode::error::DecodeError; use tokio::{ io::{AsyncWriteExt, duplex}, diff --git a/tests/server.rs b/tests/server.rs index 3c619683..031ec01d 100644 --- a/tests/server.rs +++ b/tests/server.rs @@ -1,3 +1,5 @@ +//! Tests for [`WireframeServer`] configuration. + use wireframe::{app::WireframeApp, server::WireframeServer}; #[test]