#retry #io #reconnect #stubborn #StubbornTcpStream

stubborn-io

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

13 releases

0.2.1 Oct 16, 2020
0.1.10 Jul 22, 2020
0.1.8 Jan 21, 2020
0.1.5 Nov 26, 2019
0.1.0 Jul 31, 2019

#65 in Embedded development

Download history 65/week @ 2020-07-07 14/week @ 2020-07-14 44/week @ 2020-07-21 22/week @ 2020-07-28 5/week @ 2020-08-04 41/week @ 2020-08-11 72/week @ 2020-08-18 49/week @ 2020-08-25 42/week @ 2020-09-01 42/week @ 2020-09-08 76/week @ 2020-09-15 14/week @ 2020-09-22 30/week @ 2020-09-29 22/week @ 2020-10-06 40/week @ 2020-10-13 32/week @ 2020-10-20

156 downloads per month
Used in xain-fl

MIT license

25KB
412 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.2"

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

Note: This crate requires at least version 1.39 of the Rust compiler.

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";

async {
    // 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.unwrap();
    // 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.unwrap();
};

Dependencies

~2MB
~37K SLoC