File tree Expand file tree Collapse file tree 4 files changed +25
-26
lines changed Expand file tree Collapse file tree 4 files changed +25
-26
lines changed Original file line number Diff line number Diff line change @@ -37,6 +37,7 @@ md5 = "0.7.0"
3737rand = { version = " 0.8.5" , features = [" small_rng" ] }
3838structopt = " 0.3.26"
3939tempfile = " 3.3.0"
40+ tokio = { version = " 1" , features = [" rt-multi-thread" , " macros" ] }
4041
4142# deps for tftpd-targz.rs
4243async-compression = { version = " 0.3.15" , features = [" gzip" , " futures-io" ] }
Original file line number Diff line number Diff line change @@ -33,21 +33,21 @@ Features:
3333use async_tftp :: server :: TftpServerBuilder ;
3434use async_tftp :: Result ;
3535
36- fn main () -> Result <()> {
37- smol :: block_on (async { // or any other runtime/executor
38- let tftpd = TftpServerBuilder :: with_dir_ro (" ." )? . build (). await ? ;
39- tftpd . serve (). await ? ;
40- Ok (())
41- })
36+ #[tokio:: main] // or any other runtime/executor
37+ async fn main () -> Result <()> {
38+ let tftpd = TftpServerBuilder :: with_dir_ro (" ." )? . build (). await ? ;
39+ tftpd . serve (). await ? ;
40+ Ok (())
4241}
4342```
4443
4544Add in ` Cargo.toml ` :
4645
4746``` toml
4847[dependencies ]
49- smol = " 1" # or any other runtime/executor
5048async-tftp = " 0.3"
49+ # or any other runtime/executor
50+ tokio = { version = " 1" , features = [" rt-multi-thread" , " macros" ] }
5151```
5252
5353## Running examples with cargo
Original file line number Diff line number Diff line change 11use anyhow:: Result ;
22use async_tftp:: server:: TftpServerBuilder ;
3- use futures_lite:: future:: block_on;
43
4+ #[ tokio:: main]
55fn main ( ) -> Result < ( ) > {
66 fern:: Dispatch :: new ( )
77 . level ( log:: LevelFilter :: Info )
@@ -10,17 +10,15 @@ fn main() -> Result<()> {
1010 . apply ( )
1111 . expect ( "Failed to initialize logger" ) ;
1212
13- block_on ( async {
14- let tftpd = TftpServerBuilder :: with_dir_ro ( "." ) ?
15- . bind ( "0.0.0.0:6969" . parse ( ) . unwrap ( ) )
16- // Workaround to handle cases where client is behind VPN
17- . block_size_limit ( 1024 )
18- . build ( )
19- . await ?;
13+ let tftpd = TftpServerBuilder :: with_dir_ro ( "." ) ?
14+ . bind ( "0.0.0.0:6969" . parse ( ) . unwrap ( ) )
15+ // Workaround to handle cases where client is behind VPN
16+ . block_size_limit ( 1024 )
17+ . build ( )
18+ . await ?;
2019
21- log:: info!( "Listening on: {}" , tftpd. listen_addr( ) ?) ;
22- tftpd. serve ( ) . await ?;
20+ log:: info!( "Listening on: {}" , tftpd. listen_addr( ) ?) ;
21+ tftpd. serve ( ) . await ?;
2322
24- Ok ( ( ) )
25- } )
23+ Ok ( ( ) )
2624}
Original file line number Diff line number Diff line change 2727//! use async_tftp::server::TftpServerBuilder;
2828//! use async_tftp::Result;
2929//!
30- //! fn main() -> Result<()> {
31- //! smol::block_on(async { // or any other runtime/executor
32- //! let tftpd = TftpServerBuilder::with_dir_ro(".")?.build().await?;
33- //! tftpd.serve().await?;
34- //! Ok(())
35- //! })
30+ //! #[tokio::main] // or any other runtime/executor
31+ //! async fn main() -> Result<()> {
32+ //! let tftpd = TftpServerBuilder::with_dir_ro(".")?.build().await?;
33+ //! tftpd.serve().await?;
34+ //! Ok(())
3635//! }
3736//! ```
3837//!
3938//! Add in `Cargo.toml`:
4039//!
4140//! ```toml
4241//! [dependencies]
43- //! smol = "1" # or any other runtime/executor
4442//! async-tftp = "0.3"
43+ //! # or any other runtime/executor
44+ //! tokio = { version = "1", features = ["rt-multi-thread", "macros"] }
4545//! ```
4646//!
4747//! [smol]: https://docs.rs/smol
You can’t perform that action at this time.
0 commit comments