-
Notifications
You must be signed in to change notification settings - Fork 157
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
66 changed files
with
994 additions
and
1,108 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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,38 @@ | ||
pub mod preview; | ||
pub mod preview_option_raw; | ||
pub mod preview_raw; | ||
|
||
use std::collections::HashMap; | ||
|
||
use crate::{ | ||
error::{AppError, AppErrorKind, AppResult}, | ||
preview::preview_entry::FileEntryPreviewEntry, | ||
traits::config::search_config_directories, | ||
types::config_type::ConfigType, | ||
}; | ||
|
||
use serde::{Deserialize, Serialize}; | ||
|
||
#[derive(Clone, Debug, Default, Deserialize, Serialize)] | ||
pub struct FileEntryPreview { | ||
#[serde(default)] | ||
pub extension: HashMap<String, FileEntryPreviewEntry>, | ||
#[serde(default)] | ||
pub mimetype: HashMap<String, FileEntryPreviewEntry>, | ||
} | ||
|
||
impl FileEntryPreview { | ||
pub fn from_toml_str(s: &str) -> AppResult<Self> { | ||
let res = toml::from_str(s)?; | ||
Ok(res) | ||
} | ||
|
||
pub fn get_config() -> AppResult<Self> { | ||
let file_path = search_config_directories(ConfigType::Preview.as_filename()) | ||
.ok_or_else(|| AppError::new(AppErrorKind::Config, "Cannot find config".to_string()))?; | ||
let file_contents = std::fs::read_to_string(file_path)?; | ||
Self::from_toml_str(&file_contents) | ||
} | ||
|
||
pub fn get_config_or_default() -> Self { | ||
Self::get_config().unwrap_or_default() | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
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 was deleted.
Oops, something went wrong.
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 was deleted.
Oops, something went wrong.
Oops, something went wrong.