7 个版本
0.2.3 | 2022 年 2 月 17 日 |
---|---|
0.2.2 | 2022 年 2 月 11 日 |
0.2.1 | 2022 年 1 月 31 日 |
0.1.2 | 2021 年 10 月 21 日 |
0.1.1 | 2020 年 6 月 28 日 |
#192 in 解析器实现
50,263 每月下载量
在 164 个 crate 中使用 (20 个直接使用)
31KB
770 行
eventsource-stream
从字节流数组对象构建 Eventsource 的基本构建块。要了解更多关于服务器端事件 (SSE) 的信息,请查看 MDN 文档
示例
let mut stream = reqwest::Client::new()
.get("https://127.0.0.1:7020/notifications")
.send()
.await?
.bytes_stream()
.eventsource();
while let Some(thing) = stream.next().await {
println!("{:?}", thing);
}
许可证:MIT OR Apache-2.0
lib.rs
:
从字节流数组对象构建 Eventsource 的基本构建块。要了解更多关于服务器端事件 (SSE) 的信息,请查看 MDN 文档
示例
let mut stream = reqwest::Client::new()
.get("https://127.0.0.1:7020/notifications")
.send()
.await?
.bytes_stream()
.eventsource();
while let Some(event) = stream.next().await {
match event {
Ok(event) => println!(
"received event[type={}]: {}",
event.event,
event.data
),
Err(e) => eprintln!("error occured: {}", e),
}
}
依赖项
~1MB
~21K SLoC