Skip to content

Conversation

@einarmo
Copy link
Contributor

@einarmo einarmo commented Jan 27, 2026

This was a lot easier than I expected, which is why I think we should go ahead with it. It would allow us to solve #194 much more easily, and also open for other transports.

While I'm fine with dyn in the stack, I'd really prefer to avoid boxing our futures on the critical path. An alternative to this would be to box Transport. I thought using generics would be a lot messier, but it turns out that the Session doesn't actually need the connector at all, only the event loop does. This means that we can make SessionEventLoop generic over connector type, but keep Session completely without generics.

This is acceptable to me, since I expect most users just spawn the event loop and never pass it around manually. (If they do they'll have to make methods generic over Connector, probably, like I had to in the tests). Note that none of the sample applications had any breakage due to this.

This technically already allows for external transport implementations, but it's pretty complicated, so if we're going to open up for that we probably want some layers of abstraction to make it easier to implement on the core parts of the transport. For #194 I was considering a TcpStreamTransport<R: AsyncRead, W: AsyncWrite>, or something along those lines, to replace the current TcpTransport.

There's also a separate commit with clippy lints for 1.93.

This was a lot easier than I expected, which is why I think we should go
ahead with it. It would allow us to solve #194 much more easily, and
also open for other transports.

While I'm fine with `dyn` in the stack, I'd really prefer
to avoid boxing our futures on the critical path. I thought this would
be a lot messier, but it turns out that the `Session` doesn't actually
need the connector at all, only the event loop does. This means that we
can make `SessionEventLoop` generic over connector type, but keep
`Session` completely generic.

This is acceptable to me, since I expect most users just `spawn` the
event loop and never pass it around manually. (If they do they'll have
to make methods generic over `Connector`, probably, like I had to in the
tests).

Note that none of the sample applications had any breakage due to this.
This _technically_ already allows for external transport
implementations, but it's pretty complicated, so if we're going to open
up for that we probably want some layers of abstraction to make it
easier to implement on the core parts of the transport. For #194 I was
considering a `TcpStreamTransport<R: AsyncRead, W: AsyncWrite>`, or
something along those lines, to replace the current `TcpTransport`.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants