15 unstable releases (3 breaking)

0.4.0 Feb 3, 2023
0.3.5 Oct 15, 2022
0.3.4 Aug 28, 2022
0.3.2 May 11, 2022
0.1.0 Apr 23, 2022

#19 in #graceful-shutdown

Download history 148/week @ 2023-12-03 450/week @ 2023-12-10 520/week @ 2023-12-17 199/week @ 2023-12-24 170/week @ 2023-12-31 86/week @ 2024-01-07 112/week @ 2024-01-14 112/week @ 2024-01-21 86/week @ 2024-01-28 71/week @ 2024-02-04 65/week @ 2024-02-11 401/week @ 2024-02-18 227/week @ 2024-02-25 101/week @ 2024-03-03 207/week @ 2024-03-10 98/week @ 2024-03-17

644 downloads per month
Used in 2 crates

MIT license

29KB
644 lines

Realm IO

crates.io Released API docs

Realm's high performance IO collections.

Example

use tokio::net::TcpStream;
use realm_io::{bidi_copy, bidi_zero_copy, bidi_copy_buf};
use realm_io::{Pipe, CopyBuffer};

let mut left = TcpStream::connect("abc").await.unwrap();
let mut right = TcpStream::connect("def").await.unwrap();

// direct copy     
bidi_copy(&mut left, &mut right).await;

// zero copy
bidi_zero_copy(&mut left, &mut right).await;

// use custom buffer(vector)
let buf1 = CopyBuffer::new(vec![0; 0x2000]);
let buf2 = CopyBuffer::new(vec![0; 0x2000]);
bidi_copy_buf(&mut left, &mut right, buf1, buf2).await;

// use custom buffer(pipe)
let buf1 = CopyBuffer::new(Pipe::new().unwrap());
let buf2 = CopyBuffer::new(Pipe::new().unwrap());
bidi_copy_buf(&mut left, &mut right, buf1, buf2).await;

About Brutal Shutdown

By default, bidi_copy_buf and other IO functions perform a graceful shutdown.

With the feature brutal-shutdown enabled, these IO functions will decide to perform a brutal shutdown once a FIN packet reaches, which will forcefully close two connections on both sides without waiting for a reply packet.

This is helpful when handling connections from a poorly implemented client or server, which may never shutdown its write side nor close the underlying socket.

Dependencies

~2–12MB
~98K SLoC