Struct warg_client::Client

source ·
pub struct Client<R, C, N>{ /* private fields */ }
Expand description

A client for a Warg registry.

Implementations§

source§

impl<R: RegistryStorage, C: ContentStorage, N: NamespaceMapStorage> Client<R, C, N>

source

pub fn new( url: impl IntoUrl, registry: R, content: C, namespace_map: N, auth_token: Option<Secret<String>> ) -> ClientResult<Self>

Creates a new client for the given URL, registry storage, and content storage.

source

pub fn url(&self) -> &RegistryUrl

Gets the URL of the client.

source

pub fn registry(&self) -> &R

Gets the registry storage used by the client.

source

pub fn content(&self) -> &C

Gets the content storage used by the client.

source

pub fn namespace_map(&self) -> &N

Gets the namespace map

source

pub async fn store_namespace( &self, namespace: String, registry_domain: RegistryDomain ) -> Result<()>

Stores namespace mapping in local storage

source

pub async fn reset_namespaces(&self) -> Result<()>

Resets the namespace map

source

pub async fn reset_registry(&self, all_registries: bool) -> ClientResult<()>

Reset client storage for the registry.

source

pub async fn clear_content_cache(&self) -> ClientResult<()>

Clear client content cache.

source

pub async fn refresh_namespace(&mut self, namespace: &str) -> ClientResult<()>

Check operator log for namespace mapping

source

pub fn get_warg_registry(&self) -> &Option<RegistryDomain>

Get warg-registry header value

source

pub async fn lock_component(&self, info: &PackageInfo) -> ClientResult<Vec<u8>>

Locks component

source

pub async fn bundle_component( &self, info: &PackageInfo ) -> ClientResult<Vec<u8>>

Bundles component

source

pub async fn publish(&self, signing_key: &PrivateKey) -> ClientResult<RecordId>

Submits the publish information in client storage.

If there’s no publishing information in client storage, an error is returned.

Returns the identifier of the record that was published.

Use wait_for_publish to wait for the record to transition to the published state.

source

pub async fn publish_with_info( &self, signing_key: &PrivateKey, info: PublishInfo ) -> ClientResult<RecordId>

Submits the provided publish information.

Any publish information in client storage is ignored.

Returns the identifier of the record that was published.

Use wait_for_publish to wait for the record to transition to the published state.

source

pub async fn wait_for_publish( &self, package: &PackageName, record_id: &RecordId, interval: Duration ) -> ClientResult<()>

Waits for a package record to transition to the published state.

The interval is the amount of time to wait between checks.

Returns an error if the package record was rejected.

source

pub async fn update_all(&mut self) -> ClientResult<()>

Updates every package log in every client registry storage to the latest registry checkpoint.

source

pub async fn update(&self) -> ClientResult<()>

Updates every package log in client storage to the latest registry checkpoint.

source

pub async fn upsert<'a, I>(&self, packages: I) -> Result<(), ClientError>

Inserts or updates the logs of the specified packages in client storage to the latest registry checkpoint.

source

pub async fn download( &self, name: &PackageName, requirement: &VersionReq ) -> Result<Option<PackageDownload>, ClientError>

Downloads the latest version of a package into client storage that satisfies the given version requirement.

If the requested package log is not present in client storage, it will be fetched from the registry first.

An error is returned if the package does not exist.

If a version satisfying the requirement does not exist, None is returned.

Returns the path within client storage of the package contents for the resolved version.

source

pub async fn download_exact( &self, package: &PackageName, version: &Version ) -> Result<PackageDownload, ClientError>

Downloads the specified version of a package into client storage.

If the requested package log is not present in client storage, it will be fetched from the registry first.

An error is returned if the package does not exist.

Returns the path within client storage of the package contents for the specified version.

source

pub async fn download_content( &self, digest: &AnyHash ) -> Result<PathBuf, ClientError>

Downloads the content for the specified digest into client storage.

If the content already exists in client storage, the existing path is returned.

source§

impl Client<FileSystemRegistryStorage, FileSystemContentStorage, FileSystemNamespaceMapStorage>

source

pub fn try_new_with_config( url: Option<&str>, config: &Config, auth_token: Option<Secret<String>> ) -> Result<StorageLockResult<Self>, ClientError>

Attempts to create a client for the given registry URL.

If the URL is None, the home registry URL is used; if there is no home registry URL, an error is returned.

If a lock cannot be acquired for a storage directory, then NewClientResult::Blocked is returned with the path to the directory that could not be locked.

source

pub fn new_with_config( url: Option<&str>, config: &Config, auth_token: Option<Secret<String>> ) -> Result<Self, ClientError>

Creates a client for the given registry URL.

If the URL is None, the home registry URL is used; if there is no home registry URL, an error is returned.

This method blocks if storage locks cannot be acquired.

Auto Trait Implementations§

§

impl<R, C, N> !RefUnwindSafe for Client<R, C, N>

§

impl<R, C, N> Send for Client<R, C, N>

§

impl<R, C, N> Sync for Client<R, C, N>

§

impl<R, C, N> Unpin for Client<R, C, N>
where C: Unpin, N: Unpin, R: Unpin,

§

impl<R, C, N> !UnwindSafe for Client<R, C, N>

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> 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> Same for T

§

type Output = T

Should always be Self
source§

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

§

type Error = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

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

§

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