-
Notifications
You must be signed in to change notification settings - Fork 2.7k
feat(cargo-util-schemas): Move lockfile schemas #15980
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
Conversation
Some of the fields are made public to make the moving phase easier. They will be reverted back to private when its done moving over.
simplifies the moving over of the schemas
187383c
to
949e863
Compare
Manifests schemas use `TomlManifest`. To match, we rename the lockfile schemas to `TomlLockfile`
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.
Thanks!
impl FromStr for TomlLockfilePackageId { | ||
type Err = EncodablePackageIdError; | ||
|
||
fn from_str(s: &str) -> Result<TomlLockfilePackageId, Self::Err> { |
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 parses the v1 lockfile representation for backfilling ckechsums purpose. Should we make it private and add comment around otherwise it gives a false sense if this is how we parse package id.
More like an documentation issue though.
} | ||
|
||
impl TomlLockfileSourceId { | ||
pub fn new(source: String) -> Result<Self, EncodableSourceIdError> { |
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.
Do we expect user to create SourceId from raw strings?
I know the API is pub because libcargo needs it, but I fee like this may expose an implicit dependency of the shape of source id string, which should be opaque according to our current documentation.
Changing the underlying implmemtation won't be SemVer breaking, but it may break tools relying on it and narrow their supported Rust toolchain versions if using this API.
Anyway, this is all hypothetical.
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.
In cargo plumbing, we use this to parse the source ID generated by cargo, i.e. from dependency resolution results and lockfiles. I imagine users would do the same.
### What does this PR try to resolve? Add documentation efforts to the lockfile schemas. Continuation of #15980 ### How to test and review this PR?
What does this PR try to resolve?
As part of cargo plumbing commands, we're trying to make lockfiles more accessible to third-party uses. This change moves the lockfile schemas to
cargo-util-schemas
, where it is previously undercargo
and are relatively hidden.See also: crate-ci/cargo-plumbing#82
How to test and review this PR?
Commit by commit to see the changes made. My main concern is performance as the implementation repeatedly calls
SourceId::from_url
and I'm not sure if its negligible.r? @epage