Skip to main content

HttpRegistry

Struct HttpRegistry 

Source
pub struct HttpRegistry<'gctx> {
    name: InternedString,
    registry_config: Mutex<Option<RegistryConfig>>,
    inner: HttpBackend<'gctx>,
}
Expand description

A registry served by the HTTP-based registry API.

This type is primarily accessed through the RegistryData trait.

HttpRegistry implements the HTTP-based registry API outlined in RFC 2789. Read the RFC for the complete protocol, but roughly the implementation loads each index file (e.g., config.json or re/ge/regex) from an HTTP service rather than from a locally cloned git repository. The remote service can more or less be a static file server that simply serves the contents of the origin git repository.

Implemented naively, this leads to a significant amount of network traffic, as a lookup of any index file would need to check with the remote backend if the index file has changed. This cost is somewhat mitigated by the use of HTTP conditional fetches (If-Modified-Since and If-None-Match for ETags) which can be efficiently handled by HTTP/2.

Fields§

§name: InternedString

The name of this source, a unique string (across all sources) used as the directory name where its cached content is stored.

§registry_config: Mutex<Option<RegistryConfig>>

Cached registry configuration.

§inner: HttpBackend<'gctx>

Backend used for making network requests.

Implementations§

Source§

impl<'gctx> HttpRegistry<'gctx>

Source

pub fn new( source_id: SourceId, gctx: &'gctx GlobalContext, name: &str, ) -> CargoResult<HttpRegistry<'gctx>>

Creates a HTTP-rebased remote registry for source_id.

  • name — Name of a path segment where .crate tarballs and the registry index are stored. Expect to be unique.
Source

fn inner(&self) -> &HttpBackend<'gctx>

Source

async fn config(&self) -> CargoResult<RegistryConfig>

Get the registry configuration from either cache or remote.

Source

async fn config_opt(&self) -> CargoResult<Option<RegistryConfig>>

Get the registry configuration from either cache or remote. Returns None if the config is not available.

Source

async fn config_opt_inner(&self) -> CargoResult<Option<RegistryConfig>>

Source

fn config_from_filesystem(&self) -> Option<RegistryConfig>

Get the cached registry configuration from the filesystem, if it exists.

Source

async fn sparse_fetch( &self, path: &str, index_version: Option<&str>, ) -> CargoResult<LoadResponse>

Trait Implementations§

Source§

impl<'gctx> RegistryData for HttpRegistry<'gctx>

Source§

fn prepare(&self) -> CargoResult<()>

Performs initialization for the registry. Read more
Source§

fn index_path(&self) -> &Filesystem

Returns the path to the index. Read more
Source§

fn cache_path(&self) -> &Filesystem

Returns the path of the directory that stores the cache of .crate files. Read more
Source§

fn assert_index_locked<'a>(&self, path: &'a Filesystem) -> &'a Path

Validates that the global package cache lock is held. Read more
Source§

fn is_updated(&self) -> bool

Is the local cached data up-to-date?
Source§

fn load<'life0, 'life1, 'life2, 'life3, 'async_trait>( &'life0 self, _root: &'life1 Path, path: &'life2 Path, index_version: Option<&'life3 str>, ) -> Pin<Box<dyn Future<Output = CargoResult<LoadResponse>> + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait, 'life3: 'async_trait,

Loads the JSON for a specific named package from the index. Read more
Source§

fn config<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = CargoResult<Option<RegistryConfig>>> + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Loads the config.json file and returns it. Read more
Source§

fn invalidate_cache(&self)

Invalidates locally cached data.
Source§

fn set_quiet(&mut self, quiet: bool)

If quiet, the source should not display any progress or status messages.
Source§

fn download(&self, pkg: PackageId, checksum: &str) -> CargoResult<MaybeLock>

Prepare to start downloading a .crate file. Read more
Source§

fn finish_download( &self, pkg: PackageId, checksum: &str, data: &[u8], ) -> CargoResult<File>

Finish a download by saving a .crate file to disk. Read more
Source§

fn is_crate_downloaded(&self, pkg: PackageId) -> bool

Returns whether or not the .crate file is already downloaded.

Auto Trait Implementations§

§

impl<'gctx> !Freeze for HttpRegistry<'gctx>

§

impl<'gctx> !RefUnwindSafe for HttpRegistry<'gctx>

§

impl<'gctx> Send for HttpRegistry<'gctx>

§

impl<'gctx> !Sync for HttpRegistry<'gctx>

§

impl<'gctx> Unpin for HttpRegistry<'gctx>

§

impl<'gctx> UnsafeUnpin for HttpRegistry<'gctx>

§

impl<'gctx> !UnwindSafe for HttpRegistry<'gctx>

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.

§

impl<T> Instrument for T

§

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

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

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

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
§

impl<T> Pointable for T

§

const ALIGN: usize

The alignment of pointer.
§

type Init = T

The type for initializers.
§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

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

Source§

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>,

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.
§

impl<T> WithSubscriber for T

§

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
§

fn with_current_subscriber(self) -> WithDispatch<Self>

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

Layout§

Note: Most layout information is completely unstable and may even differ between compilations. The only exception is types with certain repr(...) attributes. Please see the Rust Reference's “Type Layout” chapter for details on type layout guarantees.

Size: 616 bytes