Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make axum generic over it's Listener type #2643

Closed
wants to merge 18 commits into from

Conversation

StratusFearMe21
Copy link

@StratusFearMe21 StratusFearMe21 commented Mar 12, 2024

Motivation

I'd like making axum applications powered by Unix Sockets to be easier than having to make your own event loop from scratch. This PR allows you to put a UnixListener in axum::serve, or any other type that you implement Accept on.

Solution

This PR adds the Accept trait, which abstracts over the accept() function of the Listener type. This PR also adds the LocalAddr trait, which get's the associated Listener's Socket type's SocketAddr by calling the local_addr() function on the type. From there, changes were made all around the codebase to make sure that any type implementing Accept could be put into axum::serve

@StratusFearMe21
Copy link
Author

The idea is that the new Accept trait that this PR introduces is as flexible as possible, so as of right now, it uses hyper::rt::Read + hyper::rt::Write as trait bounds. Im totally open to suggestions though about how we can replace these trait bounds with something non-hyper

@jplatte
Copy link
Member

jplatte commented Mar 12, 2024

Did you see the existing issue at #2474 / PR at #2479?

@StratusFearMe21
Copy link
Author

Huh, somehow I didn't see those

@jplatte
Copy link
Member

jplatte commented Mar 12, 2024

That's unfortunate. I recommend next time you open an issue to discuss any non-trivial changes before making a PR. As for this change, is it okay if I close this as duplicate? Maybe your work on this could still be useful if it leads to any useful feedback on the other PR, if you want to check for any noteworthy differences and leave a review there that would be appreciated.

@StratusFearMe21
Copy link
Author

Yeah, that's fine

Duplicate of #2474 / #2479

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