Struct cargo::sources::registry::http_remote::HttpRegistry
source · pub struct HttpRegistry<'cfg> {Show 16 fields
index_path: Filesystem,
cache_path: Filesystem,
source_id: SourceId,
config: &'cfg Config,
url: Url,
multi: Multi,
requested_update: bool,
downloads: Downloads<'cfg>,
multiplexing: bool,
fresh: HashSet<PathBuf>,
fetch_started: bool,
registry_config: Option<RegistryConfig>,
auth_required: bool,
login_url: Option<Url>,
auth_error_headers: Vec<String>,
quiet: bool,
}
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 ETag
s) which can be efficiently handled by HTTP/2.
Fields§
§index_path: Filesystem
Path to the registry index ($CARGO_HOME/registry/index/$REG-HASH
).
To be fair, HttpRegistry
doesn’t store the registry index it
downloads on the file system, but other cached data like registry
configuration could be stored here.
cache_path: Filesystem
Path to the cache of .crate
files ($CARGO_HOME/registry/cache/$REG-HASH
).
source_id: SourceId
The unique identifier of this registry source.
config: &'cfg Config
§url: Url
Store the server URL without the protocol prefix (sparse+)
multi: Multi
HTTP multi-handle for asynchronous/parallel requests.
requested_update: bool
Has the client requested a cache update?
Only if they have do we double-check the freshness of each locally-stored index file.
downloads: Downloads<'cfg>
State for currently pending index downloads.
multiplexing: bool
Does the config say that we can use HTTP multiplexing?
fresh: HashSet<PathBuf>
What paths have we already fetched since the last index update?
We do not need to double-check any of these index files since we have already done so.
fetch_started: bool
Have we started to download any index files?
registry_config: Option<RegistryConfig>
Cached registry configuration.
auth_required: bool
Should we include the authorization header?
login_url: Option<Url>
Url to get a token for the registry.
auth_error_headers: Vec<String>
Headers received with an HTTP 401.
quiet: bool
Disables status messages.
Implementations§
source§impl<'cfg> HttpRegistry<'cfg>
impl<'cfg> HttpRegistry<'cfg>
sourcepub fn new(
source_id: SourceId,
config: &'cfg Config,
name: &str
) -> CargoResult<HttpRegistry<'cfg>>
pub fn new( source_id: SourceId, config: &'cfg Config, name: &str ) -> CargoResult<HttpRegistry<'cfg>>
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.
sourcefn handle_http_header(buf: &[u8]) -> Option<(&str, &str)>
fn handle_http_header(buf: &[u8]) -> Option<(&str, &str)>
Splits HTTP HEADER: VALUE
to a tuple.
sourcefn start_fetch(&mut self) -> CargoResult<()>
fn start_fetch(&mut self) -> CargoResult<()>
Setup the necessary works before the first fetch gets started.
This is a no-op if called more than one time.
sourcefn handle_completed_downloads(&mut self) -> CargoResult<()>
fn handle_completed_downloads(&mut self) -> CargoResult<()>
Checks the results inside the HttpRegistry::multi
handle, and
updates relevant state in HttpRegistry::downloads
accordingly.
sourcefn is_fresh(&self, path: &Path) -> bool
fn is_fresh(&self, path: &Path) -> bool
Check if an index file of path
is up-to-date.
The path
argument is the same as in RegistryData::load
.
sourcefn config_cached(&mut self) -> CargoResult<Option<&RegistryConfig>>
fn config_cached(&mut self) -> CargoResult<Option<&RegistryConfig>>
Get the cached registry configuration, if it exists.
sourcefn config(&mut self) -> Poll<CargoResult<&RegistryConfig>>
fn config(&mut self) -> Poll<CargoResult<&RegistryConfig>>
Get the registry configuration from either cache or remote.
sourcefn add_sleepers(&mut self) -> CargoResult<()>
fn add_sleepers(&mut self) -> CargoResult<()>
Moves failed Download
s that are ready to retry to the pending queue.
Trait Implementations§
source§impl<'cfg> RegistryData for HttpRegistry<'cfg>
impl<'cfg> RegistryData for HttpRegistry<'cfg>
source§fn index_path(&self) -> &Filesystem
fn index_path(&self) -> &Filesystem
source§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(
&mut self,
_root: &Path,
path: &Path,
index_version: Option<&str>
) -> Poll<CargoResult<LoadResponse>>
fn load( &mut self, _root: &Path, path: &Path, index_version: Option<&str> ) -> Poll<CargoResult<LoadResponse>>
source§fn config(&mut self) -> Poll<CargoResult<Option<RegistryConfig>>>
fn config(&mut self) -> Poll<CargoResult<Option<RegistryConfig>>>
config.json
file and returns it. Read moresource§fn invalidate_cache(&mut self)
fn invalidate_cache(&mut self)
source§fn set_quiet(&mut self, quiet: bool)
fn set_quiet(&mut self, quiet: bool)
source§fn download(&mut self, pkg: PackageId, checksum: &str) -> CargoResult<MaybeLock>
fn download(&mut self, pkg: PackageId, checksum: &str) -> CargoResult<MaybeLock>
.crate
file. Read moresource§fn finish_download(
&mut self,
pkg: PackageId,
checksum: &str,
data: &[u8]
) -> CargoResult<File>
fn finish_download( &mut 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.source§fn block_until_ready(&mut self) -> CargoResult<()>
fn block_until_ready(&mut self) -> CargoResult<()>
Auto Trait Implementations§
impl<'cfg> !RefUnwindSafe for HttpRegistry<'cfg>
impl<'cfg> !Send for HttpRegistry<'cfg>
impl<'cfg> !Sync for HttpRegistry<'cfg>
impl<'cfg> Unpin for HttpRegistry<'cfg>
impl<'cfg> !UnwindSafe for HttpRegistry<'cfg>
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
source§impl<T> Instrument for T
impl<T> Instrument for T
source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
source§impl<T> WithSubscriber for T
impl<T> WithSubscriber for T
source§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>,
source§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: 720 bytes