1
+ //! Access to a regstiry on the local filesystem. See [`LocalRegistry`] for more.
2
+
1
3
use crate :: core:: PackageId ;
2
4
use crate :: sources:: registry:: { LoadResponse , MaybeLock , RegistryConfig , RegistryData } ;
3
5
use crate :: util:: errors:: CargoResult ;
@@ -10,18 +12,68 @@ use std::path::Path;
10
12
use std:: task:: Poll ;
11
13
12
14
/// A local registry is a registry that lives on the filesystem as a set of
13
- /// `.crate` files with an `index` directory in the same format as a remote
15
+ /// `.crate` files with an `index` directory in the [ same format] as a remote
14
16
/// registry.
17
+ ///
18
+ /// This type is primarily accessed through the [`RegistryData`] trait.
19
+ ///
20
+ /// When a local registry is requested for a package, it simply looks into what
21
+ /// its index has under the `index` directory. When [`LocalRegistry::download`]
22
+ /// is called, a local registry verifies the checksum of the requested `.crate`
23
+ /// tarball and then unpacks it to `$CARGO_HOME/.registry/src`.
24
+ ///
25
+ /// > Note that there is a third-party subcommand [`cargo-local-registry`],
26
+ /// > which happened to be developed by a former Cargo team member when local
27
+ /// > registry was introduced. The tool is to ease the burden of maintaining
28
+ /// > local registries. However, in general the Cargo team avoids recommending
29
+ /// > any specific third-party crate. Just FYI.
30
+ ///
31
+ /// [same format]: super#the-format-of-the-index
32
+ /// [`cargo-local-registry`]: https://crates.io/crates/cargo-local-registry
33
+ ///
34
+ /// # Filesystem hierarchy
35
+ ///
36
+ /// Here is an example layout of a local registry on a local filesystem:
37
+ ///
38
+ /// ```text
39
+ /// [registry root]/
40
+ /// ├── index/ # registry index
41
+ /// │ ├── an/
42
+ /// │ │ └── yh/
43
+ /// │ │ └── anyhow
44
+ /// │ ├── ru/
45
+ /// │ │ └── st/
46
+ /// │ │ ├── rustls
47
+ /// │ │ └── rustls-ffi
48
+ /// │ └── se/
49
+ /// │ └── mv/
50
+ /// │ └── semver
51
+ /// ├── anyhow-1.0.71.crate # pre-downloaded crate tarballs
52
+ /// ├── rustls-0.20.8.crate
53
+ /// ├── rustls-ffi-0.8.2.crate
54
+ /// └── semver-1.0.17.crate
55
+ /// ```
56
+ ///
57
+ /// For general concepts of registries, see the [module-level documentation](crate::sources::registry).
15
58
pub struct LocalRegistry < ' cfg > {
59
+ /// Path to the registry index.
16
60
index_path : Filesystem ,
61
+ /// Root path of this local registry.
17
62
root : Filesystem ,
63
+ /// Path where this local registry extract `.crate` tarballs to.
18
64
src_path : Filesystem ,
19
65
config : & ' cfg Config ,
66
+ /// Whether this source has updated all package informations it may contain.
20
67
updated : bool ,
68
+ /// Disables status messages.
21
69
quiet : bool ,
22
70
}
23
71
24
72
impl < ' cfg > LocalRegistry < ' cfg > {
73
+ /// Creates a local registry at `root`.
74
+ ///
75
+ /// * `name` --- Name of a path segment where `.crate` tarballs are stored.
76
+ /// Expect to be unique.
25
77
pub fn new ( root : & Path , config : & ' cfg Config , name : & str ) -> LocalRegistry < ' cfg > {
26
78
LocalRegistry {
27
79
src_path : config. registry_source_path ( ) . join ( name) ,
0 commit comments