mod bookkeeping;
mod install;
mod refs;
mod release;
mod store;
pub use refs::Ref;
use serde::{Deserialize, Serialize};
use std::path::PathBuf;
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct Receipt {
pub name: String,
pub source: String,
pub tag: String,
pub sha256: String,
pub pinned: bool,
#[serde(default)]
pub installed_at: Option<String>,
#[serde(default)]
pub latest_tag: Option<String>,
}
type Result<T, E = ManagerError> = std::result::Result<T, E>;
#[derive(Debug, thiserror::Error)]
pub enum ManagerError {
#[error("{0}")]
User(String),
#[error("network: {0}")]
Network(String),
#[error("io: {0}")]
Io(#[from] std::io::Error),
}
pub struct Manager {
store: PathBuf,
state: PathBuf,
}
impl Manager {
pub fn new() -> Result<Manager> {
Ok(Manager {
store: store::store_root().ok_or_else(|| ManagerError::User("no data dir".into()))?,
state: store::state_root().ok_or_else(|| ManagerError::User("no state dir".into()))?,
})
}
}
#[derive(Debug, Clone)]
pub struct Installed {
pub receipt: Receipt,
pub active: bool,
pub current: Option<String>,
}