#io #reconnect #retry #tcp-stream #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

#208 in Network programming

Download history 3702/week @ 2024-01-29 3275/week @ 2024-02-05 3673/week @ 2024-02-12 4255/week @ 2024-02-19 3212/week @ 2024-02-26 3630/week @ 2024-03-04 3892/week @ 2024-03-11 4037/week @ 2024-03-18 3325/week @ 2024-03-25 3376/week @ 2024-04-01 3441/week @ 2024-04-08 3879/week @ 2024-04-15 4091/week @ 2024-04-22 3089/week @ 2024-04-29 3453/week @ 2024-05-06 3625/week @ 2024-05-13

14,392 downloads per month
Used in 2 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
~104K SLoC