Skip to main content

Module channel

Module channel 

Source
Expand description

Lock-free streaming channels with automatic SPSC → MPSC upgrade.

This module provides channels optimized for streaming data flow with:

  • SPSC mode for single-producer scenarios (fastest)
  • Automatic upgrade to MPSC when Producer::clone() is called
  • Configurable backpressure strategies
  • Zero-allocation batch operations

§Key Design

The channel type is NEVER user-specified. It starts as SPSC and automatically upgrades to MPSC when the producer is cloned.

let (producer, consumer) = streaming::channel::<u64>(1024);
assert!(!producer.is_mpsc());

let producer2 = producer.clone();  // Triggers MPSC upgrade
assert!(producer.is_mpsc());

Structs§

Consumer
Consumer handle for receiving items from a channel.
Producer
Producer handle for sending items into a channel.

Enums§

ChannelMode
Channel mode indicator.

Functions§

channel
Creates a new channel with the specified buffer size.
channel_with_config
Creates a new channel with custom configuration.