Closed jsha closed 1 year ago
Need this
I've rewritten this thanks to some very useful offline feedback from @djc. It now looks a lot more like the Rust API.
Clippy says there's a redundant clone in src/acceptor.rs#L455. (Should we set CI to deny clippy warnings? I usually like to do that in other projects I maintain.)
Regarding clippy warnings, I filed a PR: https://github.com/rustls/rustls-ffi/pull/261
Also, in light of https://github.com/rustls/rustls/issues/1045, I removed rustls_acceptor_wants_read
in the latest push and updated the rustls_acceptor
comment to describe the reading flow without it.
Fixes #155.
Since this relies on an "into" pattern (for the Accepted -> Connection transform), I've implemented the safer "into" pattern from #244: a rustls_acceptor always needs to be freed, whether its "into" method was called or not. This reduces the risk of double frees. I've introduced the new result code
rustls_result::AlreadyUsed
to cover the case when an accessor was called after the "into" method was called.I've introduced another new result code
rustls_result::AcceptorNotReady
to cover the case whenaccept()
returnsOk(None)
.For convenience I've flattened the methods from ClientHello onto
rustls_accepted
, so you don't need to get a ClientHello pointer out of therustls_accepted
, you can call the accessors directly.Since we now have an accessor returning a
rustls_str
(previously they were passed in callbacks), we needed a way to make the lifetime of arustls_str
longer than the function that made it, so I introduced anrustls_str::into_static
method.