#reconnect #retry #tokio #io #stubborn #stubborn-tcp-stream

stubborn-io

io traits/structs that automatically recover from potential disconnections/interruptions

19 releases

0.3.5 May 8, 2024
0.3.4 Jan 25, 2024
0.3.3 Dec 13, 2023
0.3.2 Sep 30, 2022
0.1.0 Jul 31, 2019

#642 in Network programming

Download history 3651/week @ 2024-11-21 3112/week @ 2024-11-28 3484/week @ 2024-12-05 2845/week @ 2024-12-12 1135/week @ 2024-12-19 281/week @ 2024-12-26 1696/week @ 2025-01-02 2502/week @ 2025-01-09 2832/week @ 2025-01-16 2680/week @ 2025-01-23 3216/week @ 2025-01-30 3729/week @ 2025-02-06 2322/week @ 2025-02-13 2905/week @ 2025-02-20 2765/week @ 2025-02-27 2180/week @ 2025-03-06

10,675 downloads per month
Used in 3 crates

MIT license

32KB
615 lines

stubborn-io

This crate provides io traits/structs that automatically recover from potential disconnections/interruptions.

To use with your project, add the following to your Cargo.toml:

stubborn-io = "0.3"

API Documentation, examples and motivations can be found here - https://docs.rs/stubborn-io .

Usage Example

In this example, we will see a drop in replacement for tokio's TcpStream, with the distinction that it will automatically attempt to reconnect in the face of connectivity failures.

use stubborn_io::StubbornTcpStream;
use tokio::io::AsyncWriteExt;

let addr = "localhost:8080";

// we are connecting to the TcpStream using the default built in options.
// these can also be customized (for example, the amount of reconnect attempts,
// wait duration, etc) using the connect_with_options method.
let mut tcp_stream = StubbornTcpStream::connect(addr).await?;
// once we acquire the wrapped IO, in this case, a TcpStream, we can
// call all of the regular methods on it, as seen below
tcp_stream.write_all(b"hello world!").await?;

Dependencies

~3–11MB
~101K SLoC