Initial pass at a source collection proxy

This commit is contained in:
Yehuda Katz + Carl Lerche 2014-06-10 16:29:25 -07:00 committed by Tim Carey-Smith
parent bbbf2dead8
commit f621ddb774
1 changed files with 39 additions and 0 deletions

View File

@ -35,3 +35,42 @@ pub trait Source {
*/
fn get(&self, packages: &[NameVer]) -> CargoResult<Vec<Package>>;
}
impl Source for Vec<Box<Source>> {
fn update(&self) -> CargoResult<()> {
for source in self.iter() {
try!(source.update());
}
Ok(())
}
fn list(&self) -> CargoResult<Vec<Summary>> {
let mut ret = Vec::new();
for source in self.iter() {
ret.push_all(try!(source.list()).as_slice());
}
Ok(ret)
}
fn download(&self, packages: &[NameVer]) -> CargoResult<()> {
for source in self.iter() {
try!(source.download(packages));
}
Ok(())
}
fn get(&self, packages: &[NameVer]) -> CargoResult<Vec<Package>> {
let mut ret = Vec::new();
for source in self.iter() {
ret.push_all(try!(source.get(packages)).as_slice());
}
Ok(ret)
}
}