Closed bahlo closed 1 year ago
Thanks for the PR, I'll take a closer look later. Though the CI already caught some instances where tests now fail to compile because they weren't updated for the API changes (there should be annotations in the "Files changed" tab). Everything else looks good at a first glance, thanks for taking care of updating the docs and README :)
PS: I'm not sure I like explicitly panic'ing - the method already returns a Result
, and I didn't realize that bind
can panic (guess I should've read the axum/hyper docs more closely). In hindsight, it would've been better to use try_bind
and bubble up failures to the caller instead of calling the panic'ing Server::bind
... but this is something that I can fixup with a non-breaking followup change (because the error type from Server::from_tcp
and Server::try_bind
is the same, i.e. hyper::Error
, which is already the error type in the dxr methods).
PPS: There's no need to worry about making any breaking changes in "main" - it's already no longer incompatible with the v0.5 branch because of the restructuring of the crates (and I've been planning some other possibly breaking changes as well, like further reducing the number of crates, for example, by making the "axum" support a non-default feature of the "dxr_server" crate instead of a separate crate).
Will take care of the tests, rg didn't show me more matches so I thought CI will catch any leftovers (and it did, yay).
And I agree re panic'ing—the only issue is that constructing a TcpListener
can fail with a io::Error
and that'd make things a bit more complicated. Happy to throw in an error enum that switches between that and a hyper error if you'd prefer that.
UUUGH. I hate that the "time" crates bump MSRV so frequently (and that the developers don't seem to consider dozens of people complaining about it a problem, see https://github.com/time-rs/time/discussions/535 ).
Looks like dxr needs to bump from 1.64 to 1.65 because time now requires rust 1.65+ 😩 In the future I'll probably check Cargo.lock into git so at least the CI won't be impacted (unless I explicitly run "cargo update" and commit the new Cargo.lock) ...
But your changes look good to me, thanks for the contribution. I'll fix the CI with a follow-up commit ...
First of all: Thanks for creating the library, really happy with it so far 💯
This moves the addr out of the arguments for
from_route
and intoserve
. It also adds a new fn to start the server:serve_listener
which allows starting the server with an existingTcpListener
.serve
now creates theTcpListener
(and panics in the same waybind
would've panic'ed) and callsserve_listener
.I know this is a breaking change. Personally I think the addr belongs into
serve
but, happy to make any changes if you prefer a different solution.