cargo::sources::registry::local

Struct LocalRegistry

Source
pub struct LocalRegistry<'gctx> {
    index_path: Filesystem,
    root: Filesystem,
    src_path: Filesystem,
    gctx: &'gctx GlobalContext,
    updated: bool,
    quiet: bool,
}
Expand description

A local registry is a registry that lives on the filesystem as a set of .crate files with an index directory in the same format as a remote registry.

This type is primarily accessed through the RegistryData trait.

When a local registry is requested for a package, it simply looks into what its index has under the index directory. When LocalRegistry::download is called, a local registry verifies the checksum of the requested .crate tarball and then unpacks it to $CARGO_HOME/.registry/src.

Note that there is a third-party subcommand cargo-local-registry, which happened to be developed by a former Cargo team member when local registry was introduced. The tool is to ease the burden of maintaining local registries. However, in general the Cargo team avoids recommending any specific third-party crate. Just FYI.

§Filesystem hierarchy

Here is an example layout of a local registry on a local filesystem:

[registry root]/
├── index/                      # registry index
│  ├── an/
│  │  └── yh/
│  │     └── anyhow
│  ├── ru/
│  │  └── st/
│  │     ├── rustls
│  │     └── rustls-ffi
│  └── se/
│     └── mv/
│        └── semver
├── anyhow-1.0.71.crate         # pre-downloaded crate tarballs
├── rustls-0.20.8.crate
├── rustls-ffi-0.8.2.crate
└── semver-1.0.17.crate

For general concepts of registries, see the module-level documentation.

Fields§

§index_path: Filesystem

Path to the registry index.

§root: Filesystem

Root path of this local registry.

§src_path: Filesystem

Path where this local registry extract .crate tarballs to.

§gctx: &'gctx GlobalContext§updated: bool

Whether this source has updated all package information it may contain.

§quiet: bool

Disables status messages.

Implementations§

Source§

impl<'gctx> LocalRegistry<'gctx>

Source

pub fn new( root: &Path, gctx: &'gctx GlobalContext, name: &str, ) -> LocalRegistry<'gctx>

Creates a local registry at root.

  • name — Name of a path segment where .crate tarballs are stored. Expect to be unique.

Trait Implementations§

Source§

impl<'gctx> RegistryData for LocalRegistry<'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 assert_index_locked<'a>(&self, path: &'a Filesystem) -> &'a Path

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

fn load( &mut self, root: &Path, path: &Path, _index_version: Option<&str>, ) -> Poll<CargoResult<LoadResponse>>

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

fn config(&mut self) -> Poll<CargoResult<Option<RegistryConfig>>>

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

fn block_until_ready(&mut self) -> CargoResult<()>

Block until all outstanding Poll::Pending requests are Poll::Ready.
Source§

fn invalidate_cache(&mut 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 is_updated(&self) -> bool

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

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

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

fn finish_download( &mut 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 LocalRegistry<'gctx>

§

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

§

impl<'gctx> !Send for LocalRegistry<'gctx>

§

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

§

impl<'gctx> Unpin for LocalRegistry<'gctx>

§

impl<'gctx> !UnwindSafe for LocalRegistry<'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.

§

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<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V

§

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: 88 bytes