* [PATCH proxmox] oci: drop unnecessary Result from layer decode_fn
@ 2026-10-13 8:30 Filip Schauer
2026-10-22 11:20 ` Wolfgang Bumiller
0 siblings, 1 reply; 2+ messages in thread
From: Filip Schauer @ 2026-10-13 8:30 UTC (permalink / raw)
To: pve-devel
zstd::Decoder::new cannot fail (see gyscos/zstd-rs#281), so simplify
DecodeFn to return Box<dyn Read> directly.
Signed-off-by: Filip Schauer <f.schauer@proxmox.com>
---
proxmox-oci/src/lib.rs | 13 +++++++------
1 file changed, 7 insertions(+), 6 deletions(-)
diff --git a/proxmox-oci/src/lib.rs b/proxmox-oci/src/lib.rs
index b274e46a..3b6dbeb0 100644
--- a/proxmox-oci/src/lib.rs
+++ b/proxmox-oci/src/lib.rs
@@ -201,16 +201,17 @@ fn extract_image_rootfs<R: Read + Seek, P: AsRef<Path>>(
.open_blob(layer_descriptor.digest())
.ok_or(ExtractError::MissingLayerFile(layer_digest))?;
- type DecodeFn<T> = Box<dyn for<'a> Fn(&'a mut T) -> io::Result<Box<dyn Read + 'a>>>;
+ type DecodeFn<T> = Box<dyn for<'a> Fn(&'a mut T) -> Box<dyn Read + 'a>>;
let decode_fn: DecodeFn<OciTarImageBlob<R>> = match layer_descriptor.media_type() {
MediaType::ImageLayer | MediaType::ImageLayerNonDistributable => {
- Box::new(|file| Ok(Box::new(file)))
+ Box::new(|file| Box::new(file))
}
MediaType::ImageLayerGzip | MediaType::ImageLayerNonDistributableGzip => {
- Box::new(|file| Ok(Box::new(GzDecoder::new(file))))
+ Box::new(|file| Box::new(GzDecoder::new(file)))
}
MediaType::ImageLayerZstd | MediaType::ImageLayerNonDistributableZstd => {
- Box::new(|file| Ok(Box::new(zstd::Decoder::new(file)?)))
+ // https://github.com/gyscos/zstd-rs/issues/281
+ Box::new(|file| Box::new(zstd::Decoder::new(file).expect("infallible")))
}
// Error on any other non-ImageLayer related media types.
// Match explicitly to avoid missing new image layer types when oci-spec updates.
@@ -226,9 +227,9 @@ fn extract_image_rootfs<R: Read + Seek, P: AsRef<Path>>(
}
};
- apply_whiteouts(&mut decode_fn(&mut layer_file)?, &target_path)?;
+ apply_whiteouts(&mut decode_fn(&mut layer_file), &target_path)?;
layer_file.seek(SeekFrom::Start(0))?;
- extract_archive(&mut decode_fn(&mut layer_file)?, &target_path)?;
+ extract_archive(&mut decode_fn(&mut layer_file), &target_path)?;
oci_tar_image = layer_file.into_oci_tar_image();
}
--
2.47.3
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH proxmox] oci: drop unnecessary Result from layer decode_fn
2026-10-13 8:30 [PATCH proxmox] oci: drop unnecessary Result from layer decode_fn Filip Schauer
@ 2026-10-22 11:20 ` Wolfgang Bumiller
0 siblings, 0 replies; 2+ messages in thread
From: Wolfgang Bumiller @ 2026-10-22 11:20 UTC (permalink / raw)
To: Filip Schauer; +Cc: pve-devel
On Tue, Oct 13, 2026 at 10:30:37AM +0200, Filip Schauer wrote:
> zstd::Decoder::new cannot fail (see gyscos/zstd-rs#281), so simplify
I don't want to rely on something happening in a dependency's wrapped
library like that.
Let's just wait for `zstd` to drop the `Result` *or* at the very least
make the error case `Infallible`/`!`.
> DecodeFn to return Box<dyn Read> directly.
>
> Signed-off-by: Filip Schauer <f.schauer@proxmox.com>
> ---
> proxmox-oci/src/lib.rs | 13 +++++++------
> 1 file changed, 7 insertions(+), 6 deletions(-)
>
> diff --git a/proxmox-oci/src/lib.rs b/proxmox-oci/src/lib.rs
> index b274e46a..3b6dbeb0 100644
> --- a/proxmox-oci/src/lib.rs
> +++ b/proxmox-oci/src/lib.rs
> @@ -201,16 +201,17 @@ fn extract_image_rootfs<R: Read + Seek, P: AsRef<Path>>(
> .open_blob(layer_descriptor.digest())
> .ok_or(ExtractError::MissingLayerFile(layer_digest))?;
>
> - type DecodeFn<T> = Box<dyn for<'a> Fn(&'a mut T) -> io::Result<Box<dyn Read + 'a>>>;
> + type DecodeFn<T> = Box<dyn for<'a> Fn(&'a mut T) -> Box<dyn Read + 'a>>;
> let decode_fn: DecodeFn<OciTarImageBlob<R>> = match layer_descriptor.media_type() {
> MediaType::ImageLayer | MediaType::ImageLayerNonDistributable => {
> - Box::new(|file| Ok(Box::new(file)))
> + Box::new(|file| Box::new(file))
> }
> MediaType::ImageLayerGzip | MediaType::ImageLayerNonDistributableGzip => {
> - Box::new(|file| Ok(Box::new(GzDecoder::new(file))))
> + Box::new(|file| Box::new(GzDecoder::new(file)))
> }
> MediaType::ImageLayerZstd | MediaType::ImageLayerNonDistributableZstd => {
> - Box::new(|file| Ok(Box::new(zstd::Decoder::new(file)?)))
> + // https://github.com/gyscos/zstd-rs/issues/281
> + Box::new(|file| Box::new(zstd::Decoder::new(file).expect("infallible")))
> }
> // Error on any other non-ImageLayer related media types.
> // Match explicitly to avoid missing new image layer types when oci-spec updates.
> @@ -226,9 +227,9 @@ fn extract_image_rootfs<R: Read + Seek, P: AsRef<Path>>(
> }
> };
>
> - apply_whiteouts(&mut decode_fn(&mut layer_file)?, &target_path)?;
> + apply_whiteouts(&mut decode_fn(&mut layer_file), &target_path)?;
> layer_file.seek(SeekFrom::Start(0))?;
> - extract_archive(&mut decode_fn(&mut layer_file)?, &target_path)?;
> + extract_archive(&mut decode_fn(&mut layer_file), &target_path)?;
>
> oci_tar_image = layer_file.into_oci_tar_image();
> }
> --
> 2.47.3
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-10-22 11:20 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-10-13 8:30 [PATCH proxmox] oci: drop unnecessary Result from layer decode_fn Filip Schauer
2026-10-22 11:20 ` Wolfgang Bumiller
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox