The type of values that can be sent through the channel.
Readonly[toThe well-known symbol Symbol.toStringTag used by Object.prototype.toString().
Returns 'Channel' so that Object.prototype.toString.call(channel) produces '[object Channel]'.
ReadonlycapacityThe maximum number of values that can be buffered.
0 for rendezvous channels, Infinity for unbounded channels.
ReadonlyisReturns true if the channel has been closed.
ReadonlyisReturns true if the channel buffer is empty.
Note: A rendezvous channel (capacity=0) is always empty.
ReadonlyisReturns true if the channel buffer is full.
Note: A rendezvous channel (capacity=0) is always full.
ReadonlylengthThe current number of values in the buffer.
Note: This does not count waiting senders/receivers; it only counts buffered items.
ReadonlyreceiverA receiver-only view of this channel.
The Receiver shares state with this channel but only exposes
receive-related methods. Useful for type-safe producer/consumer separation.
ReadonlysenderA sender-only view of this channel.
The Sender shares state with this channel but only exposes
send-related methods. Useful for type-safe producer/consumer separation.
Returns an async iterator that yields values until the channel is closed.
Closes the channel.
After closing:
send() and trySend() will return false.false.receive() will drain remaining buffered values, then return None.None after the buffer is drained.Closing is idempotent - calling close() multiple times has no effect.
Receives a value from the channel, waiting if necessary.
Some(value) immediately.None.A promise that resolves to Some(value) or None if closed and empty.
Receives a value from the channel with a timeout.
Like receive(), but returns None if the operation cannot complete
within the specified timeout.
Timeout in milliseconds.
A promise that resolves to Some(value) or None if timed out,
empty, or closed.
Sends a value into the channel, waiting if necessary.
false immediately.The value to send.
A promise that resolves to true if sent successfully, false if the channel is closed.
Sends a value into the channel with a timeout.
Like send(), but returns false if the operation cannot complete
within the specified timeout.
The value to send.
Timeout in milliseconds.
A promise that resolves to true if sent successfully,
false if timed out, channel is full, or closed.
Attempts to send a value without waiting.
true.true.false.The value to send.
true if sent successfully, false if full or closed.
An MPMC (multi-producer multi-consumer) channel for async message passing.
Channels allow multiple async tasks to communicate by sending and receiving typed values. Values are delivered in FIFO order.
Since
1.8.0
See
https://doc.rust-lang.org/std/sync/mpmc/fn.channel.html
Example
Example