[−][src]Crate surf_sse
An implementation of the EventSource API using Surf.
Surf Cargo Features
surf-sse
wraps the Surf library. By default, surf-sse
uses the default
Surf features. If you are using a non-default Surf client implementation or feature set,
you can disable surf-sse
's default feature:
surf = { version = "*", features = ["hyper-client"] }
surf-sse = { version = "*", default-features = false }
This way, surf-sse
will also use the "hyper-client" feature.
Logging
surf-sse
uses the log
crate for some rudimentary connection logging. If you need to debug
an EventSource connection, enable trace logging for the surf-sse
target. For example, with
env_logger
:
RUST_LOG=surf-sse=trace \
cargo run
Examples
use futures_util::stream::TryStreamExt; // for try_next() use surf_sse::EventSource; let mut events = EventSource::new("https://announce.u-wave.net/events".parse().unwrap()); while let Some(message) = events.try_next().await.unwrap() { dbg!(message); }
Structs
Event | An event. |
EventSource | A Server-Sent Events/Event Sourcing client, similar to |
Url | A parsed URL record. |
Enums
Error | Represents an EventSource "error" event. |
ReadyState | The state of the connection. |
Traits
ClientExt | Extension trait with event sourcing methods for Surf clients. |