Skip to main content

RegistryClient

Trait RegistryClient 

Source
pub trait RegistryClient {
    // Required methods
    async fn get_manifest(
        &self,
        image: &str,
        tag: &str,
    ) -> Result<ImageManifest>;
    async fn download_layer(
        &self,
        image: &str,
        digest: &str,
    ) -> Result<HttpResponse>;
    async fn download_layer_with_range(
        &self,
        image: &str,
        digest: &str,
        start: u64,
    ) -> Result<HttpResponse>;
    fn get_base_url(&self) -> &str;
}
Expand description

镜像仓库客户端 trait

定义了与镜像仓库交互的核心方法,包括获取镜像 manifest 和下载镜像层。

Required Methods§

Source

async fn get_manifest(&self, image: &str, tag: &str) -> Result<ImageManifest>

获取镜像 Manifest

§参数
  • image: 镜像名称
  • tag: 镜像标签
§返回
  • Result<ImageManifest>: 成功返回镜像 manifest,失败返回错误
Source

async fn download_layer( &self, image: &str, digest: &str, ) -> Result<HttpResponse>

下载镜像层

§参数
  • image: 镜像名称
  • digest: 镜像层摘要
§返回
  • Result<HttpResponse>: 成功返回 HTTP 响应,失败返回错误
Source

async fn download_layer_with_range( &self, image: &str, digest: &str, start: u64, ) -> Result<HttpResponse>

下载镜像层(支持续点续传)

§参数
  • image: 镜像名称
  • digest: 镜像层摘要
  • start: 开始下载的位置
§返回
  • Result<HttpResponse>: 成功返回 HTTP 响应,失败返回错误
Source

fn get_base_url(&self) -> &str

获取基本 URL

§返回
  • &str: 仓库的基本 URL

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§