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.
1414Example that just prints the type of each event received:
1515
1616``` rust
17- use eventsource_client :: Client ;
17+ use eventsource_client as es ;
1818
19- let mut client = Client :: for_url (" https://example.com/stream" )?
19+ let mut client = es :: ClientBuilder :: for_url (" https://example.com/stream" )?
2020 . header (" Authorization" , " Basic username:password" )?
2121 . build ();
2222
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 ));
2827```
2928
3029(Some boilerplate omitted for clarity; see [ examples directory] for complete,
Original file line number Diff line number Diff line change 1- use es:: Client ;
21use futures:: { Stream , TryStreamExt } ;
32use std:: { env, process, time:: Duration } ;
43
@@ -37,7 +36,7 @@ async fn main() -> Result<(), es::Error> {
3736 Ok ( ( ) )
3837}
3938
40- fn tail_events ( client : impl Client ) -> impl Stream < Item = Result < ( ) , ( ) > > {
39+ fn tail_events ( client : impl es :: Client ) -> impl Stream < Item = Result < ( ) , ( ) > > {
4140 client
4241 . stream ( )
4342 . map_ok ( |event| match event {
You can’t perform that action at this time.
0 commit comments