mirror of
https://github.com/anthonyoteri/dredge.git
synced 2026-06-05 23:36:53 -04:00
Create initial project structure
The initial project structure includes the base scaffolding of the application as well as the ability to fetch the repo list from the remote endpoint.
This commit is contained in:
@@ -0,0 +1,28 @@
|
||||
use crate::error::ConfigError;
|
||||
use serde::{Deserialize, Serialize};
|
||||
use std::fs;
|
||||
use std::path::Path;
|
||||
use url::Url;
|
||||
|
||||
#[derive(Debug, Clone, Eq, PartialEq, Serialize, Deserialize)]
|
||||
pub struct Config {
|
||||
pub registry_url: Url,
|
||||
}
|
||||
|
||||
impl Default for Config {
|
||||
fn default() -> Self {
|
||||
Self {
|
||||
registry_url: Url::parse("https://localhost:5000").unwrap(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl TryFrom<&Path> for Config {
|
||||
type Error = ConfigError;
|
||||
|
||||
fn try_from(path: &Path) -> Result<Self, Self::Error> {
|
||||
let contents = fs::read_to_string(path)?;
|
||||
let config: Self = toml::from_str(&contents)?;
|
||||
Ok(config)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user