Skip to content

Tidyup and prepare for 0.14 - #2

Merged
jsdw merged 21 commits into
masterfrom
jsdw-tidyup
Oct 22, 2026
Merged

jsdw merged 21 commits into
masterfrom
jsdw-tidyup

Conversation

@jsdw

@jsdw jsdw commented Oct 22, 2026 •

Copy link
Copy Markdown
Owner
  • Breaking: Remove the IntoBody trait. Unwrap body types directly instead, either by pattern matching in the handler arguments (eg |Capped(FromJson(body)): Capped<FromJson<T>, N>| ...) or via .0.
  • Breaking: Option<T> is now described as OneOf [T, Null] (ie T | null) rather than Optional, since serde serializes None as null. Previously, clients generated from the info would wrongly expect the key to be omitted.
  • Add #[api_body(optional)] for Option<T> fields in ApiBody structs and enum variants. The field is described as Optional (ie { key?: T }), is omitted from the JSON when None, and is treated as None when missing.
  • #[api_body(flatten)] on an enum variant field is now a clear compile error rather than a confusing one.
  • Breaking: HandlerBody::handler_method() no longer defaults to POST and must be implemented by every HandlerBody type. Custom body types that relied on the default should add fn handler_method() -> Method { Method::POST }.
  • Fix Capped<T, N> always reporting POST as its handler method; it now uses T's method, so wrapping a body type that expects eg PUT no longer changes the route.
  • Breaking: Responses can now be streamed. Api::handle() and HandlerResponse::handler_response() now produce an http::Response<seamless::handler::response::Body> rather than an http::Response<Vec<u8>>. A Body is either a complete set of bytes (use Body::as_bytes() or Body::into_bytes() to get at them without streaming) or a stream of bytes::Bytes chunks (use Body::into_stream() to obtain a BodyStream, which implements futures::Stream). Code which previously used res.into_body() as a Vec<u8> can use res.into_body().into_vec() instead, though it's better to pass streaming bodies on to your HTTP framework as streams (see the Axum and Hyper examples).
  • Add a ToBinary response type, which responds with arbitrary bytes, optionally streamed from a futures::Stream or futures::AsyncRead, and which allows the content-type and content-length headers to be set. The content-length is set automatically when the body is already in memory.
  • ToJson no longer panics if the value fails to serialize (eg a map with non-string keys, or a custom Serialize impl that errors). A 500 ApiError is returned instead, with the serialization error in its internal_message.

@jsdw
jsdw merged commit 3d22055 into master Oct 22, 2026
3 checks passed
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