@@ -87,10 +87,25 @@ pub trait Source {
87
87
/// If quiet, the source should not display any progress or status messages.
88
88
fn set_quiet ( & mut self , quiet : bool ) ;
89
89
90
- /// Fetches the full package for each name and version specified.
90
+ /// Starts the process to fetch a [`Package`] for the given [`PackageId`].
91
+ ///
92
+ /// If the source already has the package available on disk, then it
93
+ /// should return immediately with [`MaybePackage::Ready`] with the
94
+ /// [`Package`]. Otherwise it should return a [`MaybePackage::Download`]
95
+ /// to indicate the URL to download the package (this is for remote
96
+ /// registry sources only).
97
+ ///
98
+ /// In the case where [`MaybePackage::Download`] is returned, then the
99
+ /// package downloader will call [`Source::finish_download`] after the
100
+ /// download has finished.
91
101
fn download ( & mut self , package : PackageId ) -> CargoResult < MaybePackage > ;
92
102
93
- /// Fetches the full package **immediately** for each name and version specified.
103
+ /// Convenience method used to **immediately** fetch a [`Package`] for the
104
+ /// given [`PackageId`].
105
+ ///
106
+ /// This may trigger a download if necessary. This should only be used
107
+ /// when a single package is needed (as in the case for `cargo install`).
108
+ /// Otherwise downloads should be batched together via [`PackageSet`].
94
109
fn download_now ( self : Box < Self > , package : PackageId , config : & Config ) -> CargoResult < Package >
95
110
where
96
111
Self : std:: marker:: Sized ,
@@ -102,7 +117,13 @@ pub trait Source {
102
117
Ok ( Package :: clone ( pkg) )
103
118
}
104
119
105
- /// Finalizes the download contents of the given [`PackageId`] to a [`Package`].
120
+ /// Gives the source the downloaded `.crate` file.
121
+ ///
122
+ /// When a source has returned [`MaybePackage::Download`] in the
123
+ /// [`Source::download`] method, then this function will be called with
124
+ /// the results of the download of the given URL. The source is
125
+ /// responsible for saving to disk, and returning the appropriate
126
+ /// [`Package`].
106
127
fn finish_download ( & mut self , pkg_id : PackageId , contents : Vec < u8 > ) -> CargoResult < Package > ;
107
128
108
129
/// Generates a unique string which represents the fingerprint of the
0 commit comments