pub struct Control { /* private fields */ }Expand description
A (remote) control for opening new streams and registration of inbound protocols.
A Control can be cloned and thus allows for concurrent access.
Implementations§
Source§impl Control
impl Control
Sourcepub async fn open_stream(
&mut self,
peer: PeerId,
protocol: StreamProtocol,
) -> Result<Stream, OpenStreamError>
pub async fn open_stream( &mut self, peer: PeerId, protocol: StreamProtocol, ) -> Result<Stream, OpenStreamError>
Attempt to open a new stream for the given protocol and peer.
In case we are currently not connected to the peer, we will attempt to make a new connection.
§Backpressure
Controls support backpressure similarly to bounded channels:
Each Control has a guaranteed slot for internal messages.
A single control will always open one stream at a
time which is enforced by requiring &mut self.
This backpressure mechanism breaks if you clone Controls excessively.
Sourcepub fn accept(
&mut self,
protocol: StreamProtocol,
) -> Result<IncomingStreams, AlreadyRegistered>
pub fn accept( &mut self, protocol: StreamProtocol, ) -> Result<IncomingStreams, AlreadyRegistered>
Accept inbound streams for the provided protocol.
To stop accepting streams, simply drop the returned IncomingStreams handle.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Control
impl RefUnwindSafe for Control
impl Send for Control
impl Sync for Control
impl Unpin for Control
impl UnwindSafe for Control
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more