Uh oh!
There was an error while loading. Please reload this page.
feat: add Default and constructors to ServerSseMessage - #794
Conversation
DaleSeo
left a comment
There was a problem hiding this comment.
Can we add lightweight tests that assert field values for ServerSseMessage::new, ServerSseMessage::priming and Default? It would guard against accidental regressions if the type or helpers evolve.
Uh oh!
There was an error while loading. Please reload this page.
erenatas
commented
Apr 8, 2026
Yes, thank you for the suggestion. On it |
erenatas
commented
Apr 8, 2026
I updated with basic tests, if you won't mind I fixed couple issues with tests that prevented me to run |
Uh oh!
There was an error while loading. Please reload this page.
Motivation and Context
ServerSseMessage is #[non_exhaustive] but has no public constructor,
Defaultimpl, or builder, making it impossible for downstreamSessionManagerimplementations to produce these values withoutunsafe.This change adds
#[derive(Default)]and two named constructors covering the common patterns:ServerSseMessage::new(event_id, message)— JSON-RPC content withan event ID
ServerSseMessage::priming(event_id, retry)— priming event perSEP-1699
Update all internal call sites in tower.rs and local.rs to use the new API.
How Has This Been Tested?
Tested in an rmcp based project. Pre-existing tests in
tower.rsandlocal.rscontinue to pass — these exercise the SSE stream paths that now use the new constructors.Note: the existing
http_headertest module on main has a pre-existing compilation error (references a renamed functionextract_scope_from_header); this is unrelated to this change.Breaking Changes
None. This is a purely additive change:
Default is a new trait impl on an existing public type.
new() and priming() are new inherent methods.
No existing API surface is modified or removed.
Types of changes
Checklist