Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,8 @@ project:
- Run cargo fmt, cargo clippy -- -D warnings, and RUSTFLAGS="-D warnings" cargo
test before committing.
- Clippy warnings MUST be disallowed.
- Fix any warnings emitted during tests in the code itself rather than silencing them.
- Fix any warnings emitted during tests in the code itself rather than
silencing them.
- Where a function is too long, extract meaningfully named helper functions
adhering to separation of concerns and CQRS.
- Where a function has too many parameters, group related parameters in
Expand Down
11 changes: 5 additions & 6 deletions docs/preamble-validator.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,8 @@ and `on_preamble_decode_failure` on `WireframeServer`.

## Call Order

`WireframeServer::with_preamble::<T>()` must be called **before**
registering callbacks with `on_preamble_decode_success` or
`on_preamble_decode_failure`. The method converts the server to use a
custom preamble type, dropping any callbacks configured on the default
`()` preamble. Registering callbacks after calling `with_preamble::<T>()`
ensures they are retained.
`WireframeServer::with_preamble::<T>()` must be called **before** registering
callbacks with `on_preamble_decode_success` or `on_preamble_decode_failure`. The
method converts the server to use a custom preamble type, dropping any callbacks
configured on the default `()` preamble. Registering callbacks after calling
`with_preamble::<T>()` ensures they are retained.
90 changes: 46 additions & 44 deletions docs/roadmap.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,26 +9,28 @@ after formatting. Line numbers below refer to that file.
- [ ] Lines 316-345 outline the layered architecture comprising the Transport
Layer Adapter, Framing Layer, Serialization engine, Routing engine, Handler
invocation, and Middleware chain.

- [x] Implement derive macros or wrappers for message serialization (lines
329-333).

- [ ] Build the Actix-inspired API around `WireframeApp` and `WireframeServer`
as described in lines 586-676.
- [ ] Implement `WireframeApp` builder.
Clarify method signatures (`new`, `route`, `service`, `wrap`),
expose a consistent `Result<Self>` error strategy, and allow
registration calls in any order for ergonomic chaining.
- [x] Implement `WireframeServer`.
Worker tasks are spawned using Tokio. Each thread receives its own
`WireframeApp` instance from a factory closure. A Ctrl+C signal triggers
graceful shutdown, notifying all workers to stop accepting new
connections.
- [x] Standardize supporting trait definitions.
Provide naming conventions and generic bounds for the
`FrameProcessor` trait, state extractors and middleware via
`async_trait` and associated types.
- [x] Provide a minimal, runnable example.
Include imports and an async `main` so the snippet compiles out of
the box.

- [ ] Implement `WireframeApp` builder. Clarify method signatures (`new`,
`route`, `service`, `wrap`), expose a consistent `Result<Self>` error
strategy, and allow registration calls in any order for ergonomic chaining.

- [x] Implement `WireframeServer`. Worker tasks are spawned using Tokio. Each
thread receives its own `WireframeApp` instance from a factory closure. A
Ctrl+C signal triggers graceful shutdown, notifying all workers to stop
accepting new connections.

- [x] Standardize supporting trait definitions. Provide naming conventions and
generic bounds for the `FrameProcessor` trait, state extractors and
middleware via `async_trait` and associated types.

- [x] Provide a minimal, runnable example. Include imports and an async `main`
so the snippet compiles out of the box.

```rust
// No extra imports required
Expand All @@ -55,39 +57,37 @@ after formatting. Line numbers below refer to that file.
}
```

- [x] Add connection preamble support.
Provide generic parsing of connection preambles with a Hotline handshake
example in the tests. Invoke user-configured callbacks on decode success
or failure. See [preamble-validator](preamble-validator.md).
- [ ] Add response serialization and transmission.
Encode handler responses using the selected serialization format and write
them back through the framing layer.
- [ ] Add connection lifecycle hooks.
Integrate setup and teardown stages, so sessions can hold state (such as a
logged-in user ID) across messages.
- [x] Add connection preamble support. Provide generic parsing of connection
preambles with a Hotline handshake example in the tests. Invoke
user-configured callbacks on decode success or failure. See
[preamble-validator](preamble-validator.md).

- [ ] Add response serialization and transmission. Encode handler responses
using the selected serialization format and write them back through the
framing layer.

- [ ] Add connection lifecycle hooks. Integrate setup and teardown stages, so
sessions can hold state (such as a logged-in user ID) across messages.

## 2. Middleware and Extractors

- [ ] Develop a minimal middleware system and extractor traits for payloads,
connection metadata, and shared state.
- [ ] Define `FromMessageRequest` for extractor types (lines 760-782).
See [`FromMessageRequest`][from-message-request] in
[`src/extractor.rs`](../src/extractor.rs).
- [ ] Define `FromMessageRequest` for extractor types (lines 760-782). See
[`FromMessageRequest`][from-message-request] in
[`src/extractor.rs`](../src/extractor.rs).
- [ ] Provide built-in extractors `Message<T>`, `ConnectionInfo`, and
`SharedState<T>` (lines 792-840). `SharedState<T>` is defined in
[`src/extractor.rs`](../src/extractor.rs#L54-L87).
- [ ] Support custom extractors implementing `FromMessageRequest`
(lines 842-858). Refer again to
[`src/extractor.rs`](../src/extractor.rs#L39-L52).
`SharedState<T>` (lines 792-840). `SharedState<T>` is defined in
[`src/extractor.rs`](../src/extractor.rs#L54-L87).
- [ ] Support custom extractors implementing `FromMessageRequest` (lines
842-858). Refer again to [`src/extractor.rs`](../src/extractor.rs#L39-L52).
- [ ] Implement middleware using `Transform`/`Service` traits and a simple
`from_fn` style variant (lines 866-899). Trait definitions live in
[`src/middleware.rs`](../src/middleware.rs#L71-L84).
`from_fn` style variant (lines 866-899). Trait definitions live in
[`src/middleware.rs`](../src/middleware.rs#L71-L84).
- [ ] Register middleware with `WireframeApp::wrap` and execute it in order
(lines 900-919). See the [`wrap` method](../src/app.rs#L73-L84).
(lines 900-919). See the [`wrap` method](../src/app.rs#L73-L84).
- [ ] Document common middleware use cases like logging and authentication
(lines 920-935).

[from-message-request]: ../src/extractor.rs#L39-L52
(lines 920-935).

## 3. Initial Examples and Documentation

Expand All @@ -105,12 +105,14 @@ after formatting. Line numbers below refer to that file.

- [ ] Create a CLI for protocol scaffolding and testing (lines 1424-1429).
- [ ] Improve debugging support and expand documentation (lines 1430-1435).
- [ ] Provide testing utilities for handlers.
Offer simple ways to drive handlers with raw frames for unit tests.
Early examples live in [`tests/server.rs`](../tests/server.rs); future
helpers may reside in a `wireframe-testing` crate.
- [ ] Provide testing utilities for handlers. Offer simple ways to drive
handlers with raw frames for unit tests. Early examples live in
[`tests/server.rs`](../tests/server.rs); future helpers may reside in a
`wireframe-testing` crate.

## 6. Community Engagement and Integration

- [ ] Collaborate with `wire-rs` for trait derivation and future enhancements
(lines 1437-1442).

[from-message-request]: ../src/extractor.rs#L39-L52
11 changes: 5 additions & 6 deletions docs/rust-binary-router-library-design.md
Original file line number Diff line number Diff line change
Expand Up @@ -671,8 +671,8 @@ similar to Actix Web's web::Data.21
manage incoming connections, task spawning for each connection, and the
overall server lifecycle. The default number of worker tasks matches the
available CPU cores, falling back to a single worker if the count cannot be
determined. This would likely be built on Tokio's networking and
runtime primitives.18
determined. This would likely be built on Tokio's networking and runtime
primitives.18

This structural similarity to Actix Web is intentional. Developers familiar with
Actix Web's application setup will find "wireframe's" approach intuitive,
Expand Down Expand Up @@ -867,10 +867,9 @@ pipeline.
by implementing a pair of traits, analogous to Actix Web's `Transform` and
`Service` traits.25

- The `Transform` trait would act as a factory for the middleware service.
Its `transform` method is annotated with `#[must_use]` (to encourage
using the returned service) and `#[inline]` for potential performance
gains.
- The `Transform` trait would act as a factory for the middleware service. Its
`transform` method is annotated with `#[must_use]` (to encourage using the
returned service) and `#[inline]` for potential performance gains.
- The `Service` trait would define the actual request/response processing
logic. Middleware would operate on "wireframe's" internal request and
response types, which could be raw frames at one level or deserialized
Expand Down
Loading