Add local and remote favorites
This commit is contained in:
parent
5f9b5d9796
commit
490c925f62
4 changed files with 357 additions and 28 deletions
|
|
@ -11,6 +11,7 @@ pub struct AppConfig {
|
|||
pub cache_quota_gb: u64,
|
||||
pub fast_image_loading: bool,
|
||||
pub locations: Vec<LocationProfile>,
|
||||
pub favorites: Vec<FavoriteEntry>,
|
||||
}
|
||||
|
||||
impl Default for AppConfig {
|
||||
|
|
@ -19,6 +20,7 @@ impl Default for AppConfig {
|
|||
cache_quota_gb: 10,
|
||||
fast_image_loading: true,
|
||||
locations: Vec::new(),
|
||||
favorites: Vec::new(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -36,6 +38,14 @@ pub struct LocationProfile {
|
|||
pub domain: String,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||
pub struct FavoriteEntry {
|
||||
pub name: String,
|
||||
pub uri: String,
|
||||
pub is_directory: bool,
|
||||
pub profile: LocationProfile,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
|
||||
#[serde(rename_all = "lowercase")]
|
||||
pub enum LocationKind {
|
||||
|
|
@ -137,16 +147,32 @@ mod tests {
|
|||
password: "plain-password".into(),
|
||||
domain: String::new(),
|
||||
}],
|
||||
favorites: vec![FavoriteEntry {
|
||||
name: "원격 만화".into(),
|
||||
uri: "sftp://example.invalid/comics/book.zip".into(),
|
||||
is_directory: false,
|
||||
profile: LocationProfile {
|
||||
name: "즐겨찾기 서버".into(),
|
||||
kind: LocationKind::Sftp,
|
||||
address: "sftp://example.invalid/comics".into(),
|
||||
username: "favorite-reader".into(),
|
||||
password: "favorite-password".into(),
|
||||
domain: String::new(),
|
||||
},
|
||||
}],
|
||||
};
|
||||
|
||||
let encoded = toml::to_string(&config).unwrap();
|
||||
let decoded: AppConfig = toml::from_str(&encoded).unwrap();
|
||||
assert_eq!(decoded.locations[0].password, "plain-password");
|
||||
assert_eq!(decoded.favorites[0].profile.username, "favorite-reader");
|
||||
assert_eq!(decoded.favorites[0].profile.password, "favorite-password");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn fast_image_loading_is_enabled_for_existing_configs() {
|
||||
let decoded: AppConfig = toml::from_str("cache_quota_gb = 10\n").unwrap();
|
||||
assert!(decoded.fast_image_loading);
|
||||
assert!(decoded.favorites.is_empty());
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue