aws/s2n-quic

Use GAT lifetimes for IO traits

camshaft opened this issue · 0 comments

Problem:

In #1734, I refactored the IO traits to be a bit simpler. However, the way it is right now still makes it difficult to implement some patterns that want to return partially owned values as part of the Self::Queue.

Solution:

To fully expand the API, the type Queue should be generic over a lifetime, which is only possible in rustc 1.65.

To work around this limitation, some unsafe code can be used to temporarily extend the lifetime of the queue while passed to the function. Since the queue is borrowed for the lifetime of the function and the inner fields are completely private it shouldn't be an issue.