File tree Expand file tree Collapse file tree 2 files changed +7
-9
lines changed Expand file tree Collapse file tree 2 files changed +7
-9
lines changed Original file line number Diff line number Diff line change @@ -14,17 +14,16 @@ Requires tokio.
14
14
Example that just prints the type of each event received:
15
15
16
16
``` rust
17
- use eventsource_client :: Client ;
17
+ use eventsource_client as es ;
18
18
19
- let mut client = Client :: for_url (" https://example.com/stream" )?
19
+ let mut client = es :: ClientBuilder :: for_url (" https://example.com/stream" )?
20
20
. header (" Authorization" , " Basic username:password" )?
21
21
. build ();
22
22
23
- client . stream ()
24
- . for_each (| event | {
25
- Ok (println! (" got an event: {}" , event . event_type))
26
- })
27
- . map_err (| e | println! (" error streaming events: {:?}" , e ));
23
+ client
24
+ . stream ()
25
+ . map_ok (| event | println! (" got event: {:?}" , event ))
26
+ . map_err (| err | eprintln! (" error streaming events: {:?}" , err ));
28
27
```
29
28
30
29
(Some boilerplate omitted for clarity; see [ examples directory] for complete,
Original file line number Diff line number Diff line change 1
- use es:: Client ;
2
1
use futures:: { Stream , TryStreamExt } ;
3
2
use std:: { env, process, time:: Duration } ;
4
3
@@ -37,7 +36,7 @@ async fn main() -> Result<(), es::Error> {
37
36
Ok ( ( ) )
38
37
}
39
38
40
- fn tail_events ( client : impl Client ) -> impl Stream < Item = Result < ( ) , ( ) > > {
39
+ fn tail_events ( client : impl es :: Client ) -> impl Stream < Item = Result < ( ) , ( ) > > {
41
40
client
42
41
. stream ( )
43
42
. map_ok ( |event| match event {
You can’t perform that action at this time.
0 commit comments