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: InternedStringThe 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>
impl<'gctx> HttpRegistry<'gctx>
Sourcepub fn new(
source_id: SourceId,
gctx: &'gctx GlobalContext,
name: &str,
) -> CargoResult<HttpRegistry<'gctx>>
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.cratetarballs and the registry index are stored. Expect to be unique.
fn inner(&self) -> &HttpBackend<'gctx>
Sourceasync fn config(&self) -> CargoResult<RegistryConfig>
async fn config(&self) -> CargoResult<RegistryConfig>
Get the registry configuration from either cache or remote.
Sourceasync fn config_opt(&self) -> CargoResult<Option<RegistryConfig>>
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.
async fn config_opt_inner(&self) -> CargoResult<Option<RegistryConfig>>
Sourcefn config_from_filesystem(&self) -> Option<RegistryConfig>
fn config_from_filesystem(&self) -> Option<RegistryConfig>
Get the cached registry configuration from the filesystem, if it exists.
async fn sparse_fetch( &self, path: &str, index_version: Option<&str>, ) -> CargoResult<LoadResponse>
Trait Implementations§
Source§impl<'gctx> RegistryData for HttpRegistry<'gctx>
impl<'gctx> RegistryData for HttpRegistry<'gctx>
Source§fn index_path(&self) -> &Filesystem
fn index_path(&self) -> &Filesystem
Source§fn cache_path(&self) -> &Filesystem
fn cache_path(&self) -> &Filesystem
.crate files. Read moreSource§fn assert_index_locked<'a>(&self, path: &'a Filesystem) -> &'a Path
fn assert_index_locked<'a>(&self, path: &'a Filesystem) -> &'a Path
Source§fn is_updated(&self) -> bool
fn is_updated(&self) -> bool
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,
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,
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,
fn config<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = CargoResult<Option<RegistryConfig>>> + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
config.json file and returns it. Read moreSource§fn invalidate_cache(&self)
fn invalidate_cache(&self)
Source§fn set_quiet(&mut self, quiet: bool)
fn set_quiet(&mut self, quiet: bool)
Source§fn download(&self, pkg: PackageId, checksum: &str) -> CargoResult<MaybeLock>
fn download(&self, pkg: PackageId, checksum: &str) -> CargoResult<MaybeLock>
.crate file. Read moreSource§fn finish_download(
&self,
pkg: PackageId,
checksum: &str,
data: &[u8],
) -> CargoResult<File>
fn finish_download( &self, pkg: PackageId, checksum: &str, data: &[u8], ) -> CargoResult<File>
.crate file to disk. Read moreSource§fn is_crate_downloaded(&self, pkg: PackageId) -> bool
fn is_crate_downloaded(&self, pkg: PackageId) -> bool
.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> 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
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
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
impl<T> Pointable for T
§impl<T> WithSubscriber for T
impl<T> WithSubscriber for T
§fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>where
S: Into<Dispatch>,
fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>where
S: Into<Dispatch>,
§fn with_current_subscriber(self) -> WithDispatch<Self>
fn with_current_subscriber(self) -> WithDispatch<Self>
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