Problem:
ConnectionFuture currently requires a 'static lifetime bound.
|
pub trait ConnectionFuture: 'static + Send + Sync { |
|
fn poll( |
|
self: Pin<&mut Self>, |
|
connection: &mut Connection, |
|
ctx: &mut core::task::Context, |
|
) -> Poll<Result<(), Error>>; |
|
} |
This means that async closures can only hold owned values.
This is a problem for items like the PskSelectionCallback. A synchronus PskSelectionCallback might look like
trait PskSelect {
fn select_psk(connection: &mut Connection, offered_psk: &OfferedPskList);
}
How can this callback be exposed in an async manner? The &OfferedPskList can not be held in an async closure because it does not have a 'static lifetime.
We can sometimes "hack" around this because the ConnectionFuture gives access to the &mut connection in the poll method, but there is no getter to retrieve the OfferedPskList from the connection.
Solution:
Unknown.
Potential Option 1: Shove a lifetime parameter into ConnectionFuture. This would be a breaking chance, and also be quite ugly. Therefore it is not ideal.
Requirements / Acceptance Criteria:
We need a design pattern that will support s2n-tls async callbacks.
Out of scope:
Is there anything the solution will intentionally NOT address?
Resources
There is a good exploration of s2n-tls rust bindings async stuff here: https://github.com/jmayclin/s2n-tls-docs/blob/main/async-callback-development-journal.md
Problem:
ConnectionFuturecurrently requires a'staticlifetime bound.s2n-tls/bindings/rust/extended/s2n-tls/src/callbacks/async_cb.rs
Lines 29 to 35 in 83dcc99
This means that async closures can only hold owned values.
This is a problem for items like the PskSelectionCallback. A synchronus PskSelectionCallback might look like
How can this callback be exposed in an async manner? The
&OfferedPskListcan not be held in an async closure because it does not have a'staticlifetime.We can sometimes "hack" around this because the
ConnectionFuturegives access to the&mut connectionin the poll method, but there is no getter to retrieve theOfferedPskListfrom the connection.Solution:
Unknown.
Potential Option 1: Shove a lifetime parameter into
ConnectionFuture. This would be a breaking chance, and also be quite ugly. Therefore it is not ideal.Requirements / Acceptance Criteria:
We need a design pattern that will support s2n-tls async callbacks.
Out of scope:
Is there anything the solution will intentionally NOT address?
Resources
There is a good exploration of s2n-tls rust bindings async stuff here: https://github.com/jmayclin/s2n-tls-docs/blob/main/async-callback-development-journal.md