-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactor asset picker to operate on
Keys<...>
where the keys are as…
…set names It never looked at the `Asset.url` field, so having it work with an owned `Vec<Asset>` was pointless. This is step 1 of adding support for checksums, since to do that we have to preserve the original list of assets, so we can find the checksums file after we pick the release asset we want to download.
- Loading branch information
Showing
7 changed files
with
151 additions
and
112 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
use serde::{Deserialize, Serialize}; | ||
use std::{ | ||
collections::HashMap, | ||
ops::{Deref, DerefMut}, | ||
}; | ||
use url::Url; | ||
|
||
#[derive(Clone, Debug, Deserialize, PartialEq, Eq, Serialize)] | ||
pub(crate) struct Asset { | ||
pub(crate) name: String, | ||
pub(crate) url: Url, | ||
} | ||
|
||
#[derive(Debug, PartialEq, Eq)] | ||
pub(crate) struct Assets(HashMap<String, Url>); | ||
|
||
impl From<Vec<Asset>> for Assets { | ||
fn from(assets: Vec<Asset>) -> Assets { | ||
Assets(assets.into_iter().map(|a| (a.name, a.url)).collect()) | ||
} | ||
} | ||
|
||
impl FromIterator<Asset> for Assets { | ||
fn from_iter<I: IntoIterator<Item = Asset>>(iter: I) -> Self { | ||
Assets(iter.into_iter().map(|a| (a.name, a.url)).collect()) | ||
} | ||
} | ||
|
||
impl Deref for Assets { | ||
type Target = HashMap<String, Url>; | ||
|
||
fn deref(&self) -> &Self::Target { | ||
&self.0 | ||
} | ||
} | ||
|
||
impl DerefMut for Assets { | ||
fn deref_mut(&mut self) -> &mut Self::Target { | ||
&mut self.0 | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.