#reconnect #tcp-stream #retry #stubborn-tcp-stream #stubborn

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

#512 in Network programming

Download history 2204/week @ 2025-05-28 2972/week @ 2025-06-04 3655/week @ 2025-06-11 4431/week @ 2025-06-18 4918/week @ 2025-06-25 4363/week @ 2025-07-02 4331/week @ 2025-07-09 4720/week @ 2025-07-16 3688/week @ 2025-07-23 3425/week @ 2025-07-30 4388/week @ 2025-08-06 5123/week @ 2025-08-13 5608/week @ 2025-08-20 4762/week @ 2025-08-27 4525/week @ 2025-09-03 3781/week @ 2025-09-10

19,608 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

~2–11MB
~99K SLoC