Open jhpratt opened 4 years ago
Yea, I've been meaning for the sse
module to be redesigned to return simple structs. I've written that up in #645.
Sounds good; I'll leave this open as a sub-feature. Once I finish up my project and have some free time, I'll see what I can do to contribute.
I am currently doing
where
Event
is defined asThis allows me to merge three streams into one, using a single, known type (
Event
). I am then using the first block to actually create the server-sent events, which are then streamed in an endpoint. When trying to compile this, I receive an error.The issue is clearly that warp is returning
impl ServerSentEvent
, which the compiler considers to be a unique type. A quick look at the source code as indicated shows thatfn json()
returns a parameterizedSseJson
, as is the case with other methods. I believe it would be feasible to serialize the data immediately, storing the resultingString
in an unparameterized struct. This would consequently allow the return of a non-opaque type, eliminating the current necessity to useEither
in a number of cases like this.