From: Yehuda Katz + Carl Lerche Date: Tue, 10 Jun 2014 23:29:25 +0000 (-0700) Subject: Initial pass at a source collection proxy X-Git-Tag: archive/raspbian/0.35.0-2+rpi1~3^2^2^2^2^2^2^2~1022 X-Git-Url: https://dgit.raspbian.org/?a=commitdiff_plain;h=f621ddb774c81afda41d7f72882c9c7cad0e5c20;p=cargo.git Initial pass at a source collection proxy --- diff --git a/src/cargo/core/source.rs b/src/cargo/core/source.rs index 6bb1bee1a..724fd5521 100644 --- a/src/cargo/core/source.rs +++ b/src/cargo/core/source.rs @@ -35,3 +35,42 @@ pub trait Source { */ fn get(&self, packages: &[NameVer]) -> CargoResult>; } + +impl Source for Vec> { + + fn update(&self) -> CargoResult<()> { + for source in self.iter() { + try!(source.update()); + } + + Ok(()) + } + + fn list(&self) -> CargoResult> { + 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> { + let mut ret = Vec::new(); + + for source in self.iter() { + ret.push_all(try!(source.get(packages)).as_slice()); + } + + Ok(ret) + } +}