feat!: Remove until & remove option from accept #41
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Accepting a connection in all cases that I am aware of is an operation that either succeeds or gives an error. It doesn't really make sense for it to return an
Option<Result<...>>
. Changing the return type to justResult<..>
simplifies not only this library, but also any additional implementations ofAsyncAccept
and any usages ofTlsListener.accept()
.The one use case, where we needed an
Option
was if theAsyncAccept
trait was configured to end when another future finished first. However, this functionality is already (mostly) available with theStreamExt::take_until
method.I will note that the behavior with take_until is slightly different. With the previous
Until
impementation, if a tcp connection had been successfully established, but the TLS handshake hadn't been established yet, when the finalization future completed, then we would continue processing that connection.However, with
StreamExt::take_until
, sucha connection would be dropped, since it checks the finalizaition future before polling the stream. I hope that in the vast majority of cases this doesn't really matter, or is a better behavior.
BREAKING CHANGE: remove
until
from AsyncAccept trait. UseStreamExt.take_until
on the TlsListener instead.BREAKING CHANGE:
accept
fn on AsyncAccept trait no longer returns anOption
BREAKING CHANGE:
accept
fn on TlsListener no longer returns an Option