-
Notifications
You must be signed in to change notification settings - Fork 50
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
image: impl From<MediaType> for String #146
Merged
saschagrunert
merged 2 commits into
youki-dev:main
from
waynr:impl-from-MediaType-for-String
Oct 4, 2023
Merged
image: impl From<MediaType> for String #146
saschagrunert
merged 2 commits into
youki-dev:main
from
waynr:impl-from-MediaType-for-String
Oct 4, 2023
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Signed-off-by: wayne warren <wayne.warren.s@gmail.com>
Codecov Report
Additional details and impacted files@@ Coverage Diff @@
## main #146 +/- ##
==========================================
- Coverage 22.61% 22.43% -0.19%
==========================================
Files 23 23
Lines 2069 2086 +17
Branches 1146 1148 +2
==========================================
Hits 468 468
- Misses 791 808 +17
Partials 810 810 |
src/image/mod.rs
Outdated
Comment on lines
128
to
153
impl From<MediaType> for String { | ||
fn from(media_type: MediaType) -> Self { | ||
match media_type { | ||
MediaType::Descriptor => "application/vnd.oci.descriptor".to_string(), | ||
MediaType::LayoutHeader => "application/vnd.oci.layout.header.v1+json".to_string(), | ||
MediaType::ImageManifest => "application/vnd.oci.image.manifest.v1+json".to_string(), | ||
MediaType::ImageIndex => "application/vnd.oci.image.index.v1+json".to_string(), | ||
MediaType::ImageLayer => "application/vnd.oci.image.layer.v1.tar".to_string(), | ||
MediaType::ImageLayerGzip => "application/vnd.oci.image.layer.v1.tar+gzip".to_string(), | ||
MediaType::ImageLayerZstd => "application/vnd.oci.image.layer.v1.tar+zstd".to_string(), | ||
MediaType::ImageLayerNonDistributable => { | ||
"application/vnd.oci.image.layer.nondistributable.v1.tar".to_string() | ||
} | ||
MediaType::ImageLayerNonDistributableGzip => { | ||
"application/vnd.oci.image.layer.nondistributable.v1.tar+gzip".to_string() | ||
} | ||
MediaType::ImageLayerNonDistributableZstd => { | ||
"application/vnd.oci.image.layer.nondistributable.v1.tar+zstd".to_string() | ||
} | ||
MediaType::ImageConfig => "application/vnd.oci.image.config.v1+json".to_string(), | ||
MediaType::ArtifactManifest => "application/vnd.oci.artifact.manifest.v1+json".to_string(), | ||
MediaType::EmptyJSON => "application/vnd.oci.empty.v1+json".to_string(), | ||
MediaType::Other(media) => media.to_string(), | ||
} | ||
} | ||
} |
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.
We have to apply rustfmt here:
diff --git a/src/image/mod.rs b/src/image/mod.rs
index 7c069c7..571e10c 100644
--- a/src/image/mod.rs
+++ b/src/image/mod.rs
@@ -145,7 +145,[9](https://github.com/containers/oci-spec-rs/actions/runs/6334296245/job/17203694086?pr=146#step:3:10) @@ impl From<MediaType> for String {
"application/vnd.oci.image.layer.nondistributable.v1.tar+zstd".to_string()
}
MediaType::ImageConfig => "application/vnd.oci.image.config.v1+json".to_string(),
- MediaType::ArtifactManifest => "application/vnd.oci.artifact.manifest.v1+json".to_string(),
+ MediaType::ArtifactManifest => {
+ "application/vnd.oci.artifact.manifest.v1+json".to_string()
+ }
MediaType::EmptyJSON => "application/vnd.oci.empty.v1+json".to_string(),
MediaType::Other(media) => media.to_string(),
}
@waynr may I ask you to squash your commits or sign-off the last one? |
waynr
force-pushed
the
impl-from-MediaType-for-String
branch
from
October 2, 2023 16:04
05ea4d3
to
867ff92
Compare
Signed-off-by: wayne warren <wayne.warren.s@gmail.com>
utam0k
approved these changes
Oct 3, 2023
@saschagrunert WDYT? |
saschagrunert
approved these changes
Oct 4, 2023
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
I considered converting the media type strings to constants so they can be
referenced without allocating a String but since these types aren't
comprehensive (ie we always have to deal with unknown types so we could never
impl From<String> for &'static str
) I don't think that's necessary.Signed-off-by: wayne warren wayne.warren.s@gmail.com