refact(rustup): RustupPackage::from_pacdef_packages
This commit is contained in:
@@ -62,7 +62,7 @@ impl Backend for Rustup {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn install_packages(&self, packages: &[Package], _: bool) -> Result<ExitStatus> {
|
fn install_packages(&self, packages: &[Package], _: bool) -> Result<ExitStatus> {
|
||||||
let packages = convert_all_packages_to_rustup_packages(packages)?;
|
let packages = RustupPackage::from_pacdef_packages(packages)?;
|
||||||
|
|
||||||
let (toolchains, components) =
|
let (toolchains, components) =
|
||||||
helpers::sort_packages_into_toolchains_and_components(packages);
|
helpers::sort_packages_into_toolchains_and_components(packages);
|
||||||
@@ -74,7 +74,7 @@ impl Backend for Rustup {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn remove_packages(&self, packages: &[Package], _: bool) -> Result<ExitStatus> {
|
fn remove_packages(&self, packages: &[Package], _: bool) -> Result<ExitStatus> {
|
||||||
let rustup_packages = convert_all_packages_to_rustup_packages(packages)?;
|
let rustup_packages = RustupPackage::from_pacdef_packages(packages)?;
|
||||||
|
|
||||||
let (toolchains, components) =
|
let (toolchains, components) =
|
||||||
helpers::sort_packages_into_toolchains_and_components(rustup_packages);
|
helpers::sort_packages_into_toolchains_and_components(rustup_packages);
|
||||||
@@ -86,22 +86,6 @@ impl Backend for Rustup {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn convert_all_packages_to_rustup_packages(packages: &[Package]) -> Result<Vec<RustupPackage>> {
|
|
||||||
let mut result = vec![];
|
|
||||||
|
|
||||||
for package in packages {
|
|
||||||
let rustup_package = RustupPackage::try_from(package).with_context(|| {
|
|
||||||
format!(
|
|
||||||
"converting pacdef package {} to rustup package",
|
|
||||||
package.name
|
|
||||||
)
|
|
||||||
})?;
|
|
||||||
result.push(rustup_package);
|
|
||||||
}
|
|
||||||
|
|
||||||
Ok(result)
|
|
||||||
}
|
|
||||||
|
|
||||||
impl Rustup {
|
impl Rustup {
|
||||||
pub(crate) fn new() -> Self {
|
pub(crate) fn new() -> Self {
|
||||||
Self {
|
Self {
|
||||||
|
|||||||
@@ -84,6 +84,22 @@ impl RustupPackage {
|
|||||||
component,
|
component,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn from_pacdef_packages(packages: &[Package]) -> Result<Vec<Self>> {
|
||||||
|
let mut result = vec![];
|
||||||
|
|
||||||
|
for package in packages {
|
||||||
|
let rustup_package = Self::try_from(package).with_context(|| {
|
||||||
|
format!(
|
||||||
|
"converting pacdef package {} to rustup package",
|
||||||
|
package.name
|
||||||
|
)
|
||||||
|
})?;
|
||||||
|
result.push(rustup_package);
|
||||||
|
}
|
||||||
|
|
||||||
|
Ok(result)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl TryFrom<&Package> for RustupPackage {
|
impl TryFrom<&Package> for RustupPackage {
|
||||||
|
|||||||
Reference in New Issue
Block a user