1use crate::paths::CacheLayout;
5use serde::{Deserialize, Serialize};
6
7#[derive(Debug, Clone, Default, Serialize, Deserialize)]
8pub struct RepoState {
9 pub disabled: bool,
10}
11
12pub fn load(layout: &CacheLayout) -> RepoState {
13 std::fs::read_to_string(layout.state_file())
14 .ok()
15 .and_then(|text| serde_json::from_str(&text).ok())
16 .unwrap_or_default()
17}
18
19pub fn save(layout: &CacheLayout, state: &RepoState) -> std::io::Result<()> {
20 let json = serde_json::to_string_pretty(state).expect("RepoState always serializes");
21 std::fs::write(layout.state_file(), json)
22}
23
24pub fn is_repo_disabled(layout: &CacheLayout) -> bool {
25 load(layout).disabled
26}