diff options
| author | Andreas Grois <andi@grois.info> | 2022-10-10 21:30:02 +0200 |
|---|---|---|
| committer | Andreas Grois <andi@grois.info> | 2022-10-10 21:37:15 +0200 |
| commit | e4ad766315879e1ff05bb111229f073f8f0ed68e (patch) | |
| tree | 4b043ff47c78b2c00c80c94ebda622c32c8b6d3d /rust/src/implementation/mod.rs | |
PassFish: Initial Commit
Well, that's a lie. But nobody needs to see all the iterations I decided
to sweep under the rug.
That said, I think the repo is, while not clean, clean enough now, to
not be embarrassed by uploading it to github.
Diffstat (limited to 'rust/src/implementation/mod.rs')
| -rw-r--r-- | rust/src/implementation/mod.rs | 70 |
1 files changed, 70 insertions, 0 deletions
diff --git a/rust/src/implementation/mod.rs b/rust/src/implementation/mod.rs new file mode 100644 index 0000000..889e743 --- /dev/null +++ b/rust/src/implementation/mod.rs @@ -0,0 +1,70 @@ +mod profiles; +mod passwordmaker; +mod pwm_macros; + +pub use self::profiles::Profiles; +pub use self::passwordmaker::PasswordMaker; +pub use self::passwordmaker::Settings; + +//------------------------------------------------------------------------------ +// helper types that are used in multiple modules. + +fn get_config_folder() -> Option<std::path::PathBuf> { + dirs::config_dir() + .map(|p| p.join("info.grois/harbour-passfish/")) +} + +#[derive(Debug)] +enum LoadError { + Xdg, + Loading(std::io::Error), + Parsing(toml::de::Error), +} +impl std::fmt::Display for LoadError { + fn fmt(&self, f : &mut std::fmt::Formatter) -> Result<(), std::fmt::Error> { + match self { + LoadError::Xdg => { write!(f, "XDG config path not found") } + LoadError::Loading(e) => { e.fmt(f) } + LoadError::Parsing(e) => { e.fmt(f) } + } + } +} +impl std::error::Error for LoadError {} +impl From<std::io::Error> for LoadError { + fn from(e : std::io::Error) -> Self { + LoadError::Loading(e) + } +} +impl From<toml::de::Error> for LoadError { + fn from(e : toml::de::Error) -> Self { + LoadError::Parsing(e) + } +} + + +#[derive(Debug)] +enum StoreError { + Xdg, + Writing(std::io::Error), + Serialization(toml::ser::Error) +} +impl std::fmt::Display for StoreError { + fn fmt(&self, f : &mut std::fmt::Formatter) -> Result<(), std::fmt::Error> { + match self { + StoreError::Xdg => { write!(f, "XDC config path not found") } + StoreError::Writing(e) => { e.fmt(f) } + StoreError::Serialization(e) => { e.fmt(f) } + } + } +} +impl std::error::Error for StoreError {} +impl From<std::io::Error> for StoreError { + fn from(e: std::io::Error) -> Self { + StoreError::Writing(e) + } +} +impl From<toml::ser::Error> for StoreError { + fn from(e: toml::ser::Error) -> Self { + StoreError::Serialization(e) + } +} |
