Skip to content

bindings: ConnectionFuture 'static bound blocks async interfaces #5469

@jmayclin

Description

@jmayclin

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions