-
-
Notifications
You must be signed in to change notification settings - Fork 393
Deduplicate packetline crates #2220
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
base: main
Are you sure you want to change the base?
Conversation
Thanks for giving it a shot, it's much appreciated! Feature-unification is the reason for requiring a differently named copy. It's very ugly, but there was no other way. |
Do you have reason to think the approach in this PR would not work? It seems like an existence proof contradicting that "there was no other way" (and I don't think it introduces substantial code duplication, although the tests might be a bit harder). |
Apologies, I didn't even look at the code yet and wanted to wait until you think it's ready for review. |
It obviously doesn't pass CI yet, but I'd like some early feedback before I try to tackle the remaining issues. I think the idea is conceptually simple: the gix-packetline crate offers both async and sync APIs, separately (both are toggled by a Cargo feature flag), and consumers explicitly use the API for the mode they want to use. I don't think there's substantially more library-level code duplication. For now, this leaves mutually exclusive features in higher-level crates alone, at some point the I/O mode will bubble up to the top-level API and then we have to decide how to best present that. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think I understand now what this PR is going for and have a feeling that it could work. Maybe gix-packetline
never needed have offer one unified codepath that can be 'toggled' async due to its primitive nature.
Now that I think about it, maybe the tests for gix-packetline
then will be more duplicated, but that should be alright as they are stable.
And yes, I agree that from here more opportunities for similar updates may show up.
c791c05
to
9c3977c
Compare
This feels like it's pretty close. Somehow some builds in the full tests end up enabling both djc-2021 dedup-packetline gitoxide $ cargo check --features lean-async
Checking gix-packetline v0.19.1 (/Users/djc/src/gitoxide/gix-packetline)
Checking gix-filter v0.20.0 (/Users/djc/src/gitoxide/gix-filter)
Checking gix-transport v0.48.0 (/Users/djc/src/gitoxide/gix-transport)
error: Cannot set both 'blocking-client' and 'async-client' features as they are mutually exclusive
--> gix-transport/src/lib.rs:92:1
|
92 | compile_error!("Cannot set both 'blocking-client' and 'async-client' features as they are mutually exclusive");
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ |
f9607bf
to
4ea089f
Compare
Ahh, I think I just didn't understand the justfile |
I've tacked on a second commit (which can be reviewed independently) to clean up the gix-packetline API in a way that seems quite a bit nicer to me. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great news! I see that this PR can be merged, I just need some more time with it, and didn't yet have time for my refactoring round.
Generally, I'd wish API improvements would be in a separate commit.
TCC
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this should be read/mod.rs
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why? There are no nested modules, right? Putting it in a directory without a need for further nesting seems pretty unidiomatic.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This can be write.rs
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's not clear what this is referring to.
#[cfg(feature = "blocking-io")] | ||
pub mod blocking_io { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's cool, I don't think I have ever seen this kind of style before. I will take some time to wrap my head around it :).
What do you mean by this? |
This means I have only done a partial armchair review without actually opening the code in an editor. When I do, I usually just make the changes I need and merge. That saves a lot of time as I don't have to go back and forth. |
Rebased onto current main. |
Trying to make a little progress on #2152 (and this copied crate stuff seems extremely ugly anyway).
Why does
cargo check
pass whilecargo check -p gix
break? Something to do with feature unification? This means I'm not getting feedback from VS Code on errors, which makes it much harder to get stuff done.