pub struct ChannelBuilder<'a, T> { /* private fields */ }Expand description
Builder type for creating channels.
Create a ChannelBuilder either with Handle::create_channel or ChannelBuilder::new.
The ChannelBuilder is used to specify which of the channels ends will be claimed by the
local client.
Note that this type is Copy and is thus not consumed by any of its methods.
Implementations§
Source§impl<'a, T> ChannelBuilder<'a, T>
impl<'a, T> ChannelBuilder<'a, T>
Sourcepub fn new(client: &'a Handle) -> Self
pub fn new(client: &'a Handle) -> Self
Creates a new ChannelBuilder.
Alternatively, Handle::create_channel can be more convenient to use, because it usually
avoids the need to import ChannelBuilder.
// Option 1
let builder = ChannelBuilder::<String>::new(&handle);
// Option 2
let builder = handle.create_channel::<String>();It’s not usually necessary to specify the item’s type explicitly, because it can be deferred by the compiler in many cases.
Sourcepub fn cast<U>(self) -> ChannelBuilder<'a, U>
pub fn cast<U>(self) -> ChannelBuilder<'a, U>
Casts the item type to a different type U.
Sourcepub async fn claim_sender(
self,
) -> Result<(PendingSender<T>, UnclaimedReceiver<T>), Error>
pub async fn claim_sender( self, ) -> Result<(PendingSender<T>, UnclaimedReceiver<T>), Error>
Creates a new channel and claims the sender.
Sourcepub async fn claim_receiver(
self,
capacity: u32,
) -> Result<(UnclaimedSender<T>, PendingReceiver<T>), Error>
pub async fn claim_receiver( self, capacity: u32, ) -> Result<(UnclaimedSender<T>, PendingReceiver<T>), Error>
Creates a new channel and claims the receiver.
A capacity of 0 will be treated as if 1 was specified instead.