pub struct TarUtils;Expand description
Tar processing utilities for layer extraction and offset calculation
Implementations§
Source§impl TarUtils
impl TarUtils
Sourcepub fn extract_layer_data(tar_path: &Path, layer_path: &str) -> Result<Vec<u8>>
pub fn extract_layer_data(tar_path: &Path, layer_path: &str) -> Result<Vec<u8>>
Extract layer data from tar archive
注意:Docker 镜像层的 digest 必须基于 gzip 压缩后的 tar 字节流计算。 本方法会自动检测数据是否已经是 gzip 格式(通过检查 gzip 魔数 0x1f 0x8b), 如果不是则进行 gzip 压缩,保证返回的数据始终为 gzip 字节流, 便于后续 digest 校验和上传。
参数 layer_path 应为 manifest.json 中的层路径(如 xxx/layer.tar 或 blobs/sha256/xxx)。
重要:Docker/Podman 中的层 digest 是基于 gzip 压缩后的 tar 内容计算的, 而不是基于原始的 tar 内容,因此必须确保正确的压缩格式。
Sourcepub fn find_layer_offset(tar_path: &Path, layer_path: &str) -> Result<u64>
pub fn find_layer_offset(tar_path: &Path, layer_path: &str) -> Result<u64>
Find the offset of a layer within the tar archive
Sourcepub fn list_tar_entries(tar_path: &Path) -> Result<Vec<(String, u64)>>
pub fn list_tar_entries(tar_path: &Path) -> Result<Vec<(String, u64)>>
Get a list of all entries in the tar archive with their sizes
Sourcepub fn validate_tar_archive(tar_path: &Path) -> Result<()>
pub fn validate_tar_archive(tar_path: &Path) -> Result<()>
Validate that a tar archive is readable and properly formatted
Sourcepub fn is_gzipped(data: &[u8]) -> bool
pub fn is_gzipped(data: &[u8]) -> bool
Check if data is in gzip format by examining the gzip magic number (0x1f 0x8b)
Auto Trait Implementations§
impl Freeze for TarUtils
impl RefUnwindSafe for TarUtils
impl Send for TarUtils
impl Sync for TarUtils
impl Unpin for TarUtils
impl UnwindSafe for TarUtils
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more