Skip to content

Feat/actix adapter - #15

Closed
crustyrustacean wants to merge 11 commits into
starfederation:mainfrom
crustyrustacean:feat/actix-adapter
Closed

crustyrustacean wants to merge 11 commits into
starfederation:mainfrom
crustyrustacean:feat/actix-adapter

Conversation

@crustyrustacean

Copy link
Copy Markdown

No description provided.

- Sse type: real streaming via HttpResponse::streaming()
- From<T> for Sse on all builders + DatastarEvent
- ReadSignals<T> extractor (FromRequest) with tracing parity
- header module ported from axum integration
- 7 integration tests (write + read sides)
- actix-hello: typewriter effect, streaming loop (single event type)
- actix-activity-feed: dashboard with auto-generate + manual events,
  path params, interleaved PatchElements/PatchSignals
- register both examples in Cargo.toml
- update README to list Actix Web integration
- actix-live-reload: dev-only live reload with cfg-gated /hotreload route,
  uses ExecuteScript + one-shot AtomicBool + infinite pending stream
- actix-test-suite: conformance suite server on /test, reads TestCase events
  and streams back SSE (ExecuteScript/PatchElements/PatchSignals)
- register both examples in Cargo.toml
- fix str_to_string clippy lint in tests
- Single-event Sse doctest: .into() was ambiguous (E0283) with multiple
  framework features enabled, since PatchElements has From impls for
  DatastarEvent, Sse, axum, rocket and warp event types. Use Sse::from.
- Streaming doctest: consts is not re-exported from the prelude (E0432);
  import it from datastar::consts.
- Includes cargo fmt for the actix adapter, examples and tests (F1).
- Alphabetize [dev-dependencies] (actix-web, urlencoding were appended
  after warp, breaking the dependencies-are-sorted CI gate).
- Apply cargo-sort canonical formatting: expand actix feature array to
  multi-line, add missing EOF newline (F4).
- README: list Actix Web and Warp among supported frameworks; fix typo.
- Makefile: add hello/live-reload/activity-feed/test-suite actix run
  targets plus aligned usage help entries.
- .gitignore: restore trailing newline.
Upstream v0.4.1 extracted the conformance test-case types into
examples/sdk_test/mod.rs, shared by the axum, warp, and rocket test-suite
examples. Adopt it here instead of carrying a private copy, which had
drifted: it lacked the namespace and view_transition_selector fields added
to PatchElements after Datastar 1.0.2.
Align ReadSignals with the adapter contract upstream settled in starfederation#12: GET and
DELETE read signals from the datastar query parameter, every other method
(including QUERY) from the JSON body.

A missing datastar parameter now deserializes as null instead of returning
400, so ReadSignals<Option<T>> yields None on a plain page load. DatastarParam
becomes Option<serde_json::Value> to match the other adapters.

Adds tests for DELETE extraction and the optional-signals behavior.
Sse boxed its stream as `dyn Stream<Item = DatastarEvent>`, which is not Send,
so a handler returning Sse would be rejected at runtime by actix-web's
multi-threaded server. Actix workers require responders to be Send.

Adds the + Send bound to the boxed stream and to Sse::new, and documents why.
All actix examples already used Send streams via asynk_strim::stream_fn, so
this is a source-compatible bound on the SDK's own type.
That bound was wrong. Actix-Web does not require responders or handler
futures to be Send: it runs handlers on the worker thread rather than
moving them across threads. Its own bounds are !Send throughout --
Handler::Future has no Send requirement, Responder has none, and
HttpResponse::streaming takes S: Stream<..> + 'static.

So the previous commit's premise (that actix would reject a non-Send
responder at runtime) was false, and the + Send bound was an artificial
restriction that would have rejected legitimate streams holding Rc or a
!Send guard across an await.

Restores the unconstrained bound and documents why it is correct. Adds
tests/nonsend.rs covering a !Send (Rc<Cell<usize>>) stream end to end.
@crustyrustacean
crustyrustacean deleted the feat/actix-adapter branch September 30, 2026 04:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant