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

stubborn-io

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

18 releases

0.3.4 Jan 25, 2024
0.3.3 Dec 13, 2023
0.3.2 Sep 30, 2022
0.3.1 Jan 5, 2021
0.1.0 Jul 31, 2019

#208 in Network programming

Download history 1195/week @ 2023-12-23 2160/week @ 2023-12-30 2894/week @ 2024-01-06 3215/week @ 2024-01-13 3204/week @ 2024-01-20 3563/week @ 2024-01-27 3358/week @ 2024-02-03 3718/week @ 2024-02-10 4173/week @ 2024-02-17 3247/week @ 2024-02-24 3627/week @ 2024-03-02 3970/week @ 2024-03-09 3954/week @ 2024-03-16 3264/week @ 2024-03-23 3453/week @ 2024-03-30 2911/week @ 2024-04-06

14,224 downloads per month
Used in 2 crates

MIT license

32KB
610 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–13MB
~114K SLoC