Skip to main content

Service

Struct Service 

Source
pub struct Service { /* private fields */ }
Expand description

A versioned TEA API base.

Paths are OpenAPI paths appended to {rootUrl}/v{advertised-version}/.

Implementations§

Source§

impl Service

Source

pub async fn download_format_to_writer<W>( &self, artifact: &Artifact, media_type: &str, writer: &mut W, ) -> Result<StreamedDownload, ClientError>
where W: AsyncWrite + Unpin + Send,

Stream one format of an artifact revision into writer.

Experimental. The writer receives bytes before the checksum comparison is possible. Use it only if you can discard them on error; prefer Service::download_format_to_file. The writer is flushed on success.

Like Service::download_format, an external url is fetched without the TEA access token.

§Errors

As Service::download_format, plus ClientError::Io when the writer fails. ClientError::Integrity is returned after the bytes were written.

Source

pub async fn download_format_to_file( &self, artifact: &Artifact, media_type: &str, dest: &Path, options: &FileDownloadOptions, ) -> Result<FileDownload, ClientError>

Stream one format of an artifact revision into a file.

Experimental. The file at dest appears only after the stream ended cleanly and the checksums passed the client’s policy; see the module documentation. dest’s parent directory must exist.

A NotDeclared integrity outcome is committed, as in Service::download_format; inspect StreamedDownload::integrity when that matters.

§Errors

As Service::download_format_to_writer; also ClientError::Io when dest exists and overwrite is not set, is a symbolic link, or cannot be created.

Source

pub async fn download_artifact_to_file( &self, id: ArtifactId, version: u64, media_type: Option<&str>, checksums: &[Checksum], dest: &Path, options: &FileDownloadOptions, ) -> Result<FileDownload, ClientError>

Stream GET /artifact/{uuid}/{version}/download into a file.

Experimental. checksums are the ones declared for the selected format; with none, the outcome is NotDeclared.

§Errors

As Service::download_format_to_file.

Source

pub async fn download_latest_artifact_to_file( &self, id: ArtifactId, media_type: Option<&str>, checksums: &[Checksum], dest: &Path, options: &FileDownloadOptions, ) -> Result<FileDownload, ClientError>

Stream GET /artifact/{uuid}/latest/download into a file.

Experimental. See Service::download_artifact_to_file.

§Errors

As Service::download_format_to_file.

Source§

impl Service

Source

pub fn root(&self) -> &str

API root without the version segment.

Source

pub fn api_version(&self) -> &str

Advertised version string used in the path.

Source

pub async fn discover_identifier( &self, tei: Option<&str>, purl: Option<&str>, ) -> Result<Vec<DiscoveryInfo>, ClientError>

Resolve a TEI or PURL on this already-known API base.

Exactly one of the arguments must be set.

§Errors

Returns ClientError::Unresolved for a TEA 404, which does not mean failover.

Source

pub async fn query_products( &self, query: &ListParams<ProductSort>, ) -> Result<Page<Product>, ClientError>

GET /products.

§Errors

Returns an error on transport failure or a non-success status.

Source

pub async fn get_product(&self, id: ProductId) -> Result<Product, ClientError>

GET /product/{uuid}.

Source

pub async fn list_product_releases( &self, id: ProductId, query: &ListParams<ReleaseSort>, ) -> Result<Page<ProductRelease>, ClientError>

GET /product/{uuid}/releases.

Source

pub async fn get_product_cle( &self, id: ProductId, ) -> Result<CleFetch, ClientError>

GET /product/{uuid}/cle.

Source

pub async fn query_product_releases( &self, query: &ListParams<ReleaseSort>, ) -> Result<Page<ProductRelease>, ClientError>

GET /productReleases.

Source

pub async fn get_product_release( &self, id: ProductReleaseId, ) -> Result<ProductReleaseWithCollection, ClientError>

GET /productRelease/{uuid}.

Source

pub async fn get_product_release_cle( &self, id: ProductReleaseId, ) -> Result<CleFetch, ClientError>

GET /productRelease/{uuid}/cle.

Source

pub async fn list_product_release_collections( &self, id: ProductReleaseId, query: &ListParams<CollectionSort>, ) -> Result<Page<Collection>, ClientError>

GET /productRelease/{uuid}/collections.

Source

pub async fn get_latest_product_release_collection( &self, id: ProductReleaseId, ) -> Result<Collection, ClientError>

GET /productRelease/{uuid}/collection/latest.

Source

pub async fn get_product_release_collection( &self, id: ProductReleaseId, version: u64, ) -> Result<Collection, ClientError>

GET /productRelease/{uuid}/collection/{version}.

Source

pub async fn query_components( &self, query: &ListParams<ComponentSort>, ) -> Result<Page<Component>, ClientError>

GET /components.

Source

pub async fn get_component( &self, id: ComponentId, ) -> Result<Component, ClientError>

GET /component/{uuid}.

Source

pub async fn list_component_releases( &self, id: ComponentId, query: &ListParams<ReleaseSort>, ) -> Result<Page<ComponentRelease>, ClientError>

GET /component/{uuid}/releases.

Source

pub async fn get_component_cle( &self, id: ComponentId, ) -> Result<CleFetch, ClientError>

GET /component/{uuid}/cle.

Source

pub async fn query_component_releases( &self, query: &ListParams<ReleaseSort>, ) -> Result<Page<ComponentRelease>, ClientError>

GET /componentReleases.

Source

pub async fn get_component_release( &self, id: ComponentReleaseId, ) -> Result<ComponentReleaseWithCollection, ClientError>

GET /componentRelease/{uuid}.

Source

pub async fn get_component_release_cle( &self, id: ComponentReleaseId, ) -> Result<CleFetch, ClientError>

GET /componentRelease/{uuid}/cle.

Source

pub async fn list_component_release_collections( &self, id: ComponentReleaseId, query: &ListParams<CollectionSort>, ) -> Result<Page<Collection>, ClientError>

GET /componentRelease/{uuid}/collections.

Source

pub async fn get_latest_component_release_collection( &self, id: ComponentReleaseId, ) -> Result<Collection, ClientError>

GET /componentRelease/{uuid}/collection/latest.

Source

pub async fn get_component_release_collection( &self, id: ComponentReleaseId, version: u64, ) -> Result<Collection, ClientError>

GET /componentRelease/{uuid}/collection/{version}.

Source

pub async fn get_latest_artifact( &self, id: ArtifactId, ) -> Result<Artifact, ClientError>

GET /artifact/{uuid}/latest.

Source

pub async fn get_artifact( &self, id: ArtifactId, version: u64, ) -> Result<Artifact, ClientError>

GET /artifact/{uuid}/{version}.

Source

pub async fn download_format( &self, artifact: &Artifact, media_type: &str, if_none_match: Option<&str>, ) -> Result<ArtifactFetch, ClientError>

Download one format of an artifact revision.

When the format has url, that external URL is fetched and the TEA access token is not sent. Otherwise the versioned download endpoint is used. Declared checksums are checked over the bytes left after HTTP content coding is removed (integrity of decoded bytes, not authenticity).

Source

pub async fn download_latest_artifact( &self, id: ArtifactId, media_type: Option<&str>, checksums: &[Checksum], if_none_match: Option<&str>, ) -> Result<ArtifactFetch, ClientError>

GET /artifact/{uuid}/latest/download.

Source

pub async fn download_artifact( &self, id: ArtifactId, version: u64, media_type: Option<&str>, checksums: &[Checksum], if_none_match: Option<&str>, ) -> Result<ArtifactFetch, ClientError>

GET /artifact/{uuid}/{version}/download.

Source

pub async fn download_signature_for_format( &self, artifact: &Artifact, media_type: &str, if_none_match: Option<&str>, ) -> Result<SignatureFetch, ClientError>

Download a detached signature for one content format.

media_type selects the artifact format, not the signature’s own media type. An external signatureUrl is fetched without a TEA access token.

Source

pub async fn download_signature( &self, id: ArtifactId, version: u64, media_type: Option<&str>, if_none_match: Option<&str>, ) -> Result<SignatureFetch, ClientError>

GET /artifact/{uuid}/{version}/signature/download.

Source

pub async fn download_latest_signature( &self, id: ArtifactId, media_type: Option<&str>, if_none_match: Option<&str>, ) -> Result<SignatureFetch, ClientError>

GET /artifact/{uuid}/latest/signature/download.

Source

pub async fn head_artifact( &self, id: ArtifactId, version: u64, media_type: Option<&str>, ) -> Result<HashMap<String, String>, ClientError>

HEAD the versioned artifact download and return the response headers without a body.

Trait Implementations§

Source§

impl Clone for Service

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more