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§
Structs§
- Ready
Timeout Error - Error returned by [
Select::ready_timeout]. - Receiver
- The receiving half of a channel.
- Recv
Error - Error returned by [
Receiver::recv]. - RecvFut
- A future representing an asynchronous receive operation.
- Recv
Stream - Select
- A handle for selecting over multiple channel operations.
- Select
Timeout Error - Error returned by [
Select::select_timeout]. - Selected
Operation - A selected operation that is ready to complete.
- Send
Error - Error returned by [
Sender::send]. - SendFut
- A future representing an asynchronous send operation.
- Sender
- The sending half of a channel.
- TrySelect
Error - Error returned by [
Select::try_select].
Enums§
- Recv
Timeout Error - Error returned by [
Receiver::recv_timeout]. - Send
Timeout Error - Error returned by [
Sender::send_timeout]. - TryRecv
Error - Error returned by [
Receiver::try_recv]. - TrySend
Error - Error returned by [
Sender::try_send].