@@ -87,10 +87,25 @@ pub trait Source {
8787 /// If quiet, the source should not display any progress or status messages.
8888 fn set_quiet ( & mut self , quiet : bool ) ;
8989
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.
91101 fn download ( & mut self , package : PackageId ) -> CargoResult < MaybePackage > ;
92102
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`].
94109 fn download_now ( self : Box < Self > , package : PackageId , config : & Config ) -> CargoResult < Package >
95110 where
96111 Self : std:: marker:: Sized ,
@@ -102,7 +117,13 @@ pub trait Source {
102117 Ok ( Package :: clone ( pkg) )
103118 }
104119
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`].
106127 fn finish_download ( & mut self , pkg_id : PackageId , contents : Vec < u8 > ) -> CargoResult < Package > ;
107128
108129 /// Generates a unique string which represents the fingerprint of the
0 commit comments