Skip to content

Commit 33b7033

Browse files
committed
docs(iroh): clarify ProtocolHandler::accept
Clarify at the connection is always closed when `accept` returns, and that the AcceptError variant doesn't really matter
1 parent dd99737 commit 33b7033

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

iroh/src/protocol.rs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,13 @@ pub trait ProtocolHandler: Send + Sync + std::fmt::Debug + 'static {
175175
///
176176
/// Can be implemented as `async fn accept(&self, connection: Connection) -> Result<()>`.
177177
///
178-
/// The returned future runs on a freshly spawned tokio task so it can be long-running.
178+
/// The returned future runs on a freshly spawned tokio task so it can be long-running. Once
179+
/// `accept()` returns, the connection is closed, so the returned future is expected
180+
/// to drive the protocol to completion. If there in a protocol error, you can
181+
/// use [`Connection::close`] to send an error code to the remote peer. Returning
182+
/// an `Err<AcceptError>` will also close the connection and log a warning, but no
183+
/// dedicated error code will be sent to the peer, so it's recommended to explicitly
184+
/// close the connection within your accept handler.
179185
///
180186
/// When [`Router::shutdown`] is called, no further connections will be accepted, and
181187
/// the futures returned by [`Self::accept`] will be aborted after the future returned

0 commit comments

Comments
 (0)