Crate linch

Crate linch 

Source
Expand description

§Linch - High-Performance Async/Sync Channel

Linch is a high-performance channel implementation that supports both synchronous and asynchronous operations. It’s designed for scenarios where you need maximum throughput and low latency with mixed sync/async workloads.

The name “linch” is short for “lined channel” - like a concrete-lined channel that provides a smooth, reliable pathway for water flow. Similarly, Linch provides a smooth, reliable pathway for data flow between different parts of your application.

§Features

  • Mixed Sync/Async: Send and receive both synchronously and asynchronously
  • High Performance: Optimized for throughput and low latency
  • Select Operations: Support for selecting over multiple channels
  • Multiple Implementations: Choose between the main channel and schannel variants

§Basic Usage

use linch::bounded;

// Create a bounded channel with capacity 10
let (sender, receiver) = bounded(10);

// Send synchronously
sender.send(42).unwrap();

// Receive synchronously
let value = receiver.recv().unwrap();
assert_eq!(value, 42);

§Async Usage

use linch::bounded;

let (sender, receiver) = bounded(10);

// Send asynchronously
sender.send_async(42).await.unwrap();

// Receive asynchronously
let value = receiver.recv_async().await.unwrap();
assert_eq!(value, 42);

§Select Operations

use linch::{bounded, Select};

let (tx1, rx1) = bounded(1);
let (tx2, rx2) = bounded(1);

tx1.send(1).unwrap();
tx2.send(2).unwrap();

let mut sel = Select::new();
let idx1 = sel.recv(&rx1);
let idx2 = sel.recv(&rx2);

let op = sel.select();
match op.index() {
    i if i == idx1 => {
        let value = op.recv(&rx1).unwrap();
        println!("Received {} from first channel", value);
    },
    i if i == idx2 => {
        let value = op.recv(&rx2).unwrap();
        println!("Received {} from second channel", value);
    },
    _ => unreachable!(),
}

Re-exports§

pub use schannel::Select as SchannelSelect;
pub use schannel::SelectedOperation as SchannelSelectedOperation;

Modules§

schannel

Structs§

ReadyTimeoutError
Error returned by [Select::ready_timeout].
Receiver
The receiving half of a channel.
RecvError
Error returned by [Receiver::recv].
RecvFut
A future representing an asynchronous receive operation.
RecvStream
Select
A handle for selecting over multiple channel operations.
SelectTimeoutError
Error returned by [Select::select_timeout].
SelectedOperation
A selected operation that is ready to complete.
SendError
Error returned by [Sender::send].
SendFut
A future representing an asynchronous send operation.
Sender
The sending half of a channel.
TrySelectError
Error returned by [Select::try_select].

Enums§

RecvTimeoutError
Error returned by [Receiver::recv_timeout].
SendTimeoutError
Error returned by [Sender::send_timeout].
TryRecvError
Error returned by [Receiver::try_recv].
TrySendError
Error returned by [Sender::try_send].

Functions§

bounded
Creates a bounded channel with the specified capacity.
unbounded
Creates an unbounded channel.