use chrono::{DateTime, Utc};
use serde::{Deserialize, Serialize};
use thiserror::Error;
#[non_exhaustive]
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq)]
pub struct LockEntry {
pub id: String,
pub sha: String,
pub branch: String,
pub installed_at: DateTime<Utc>,
pub actions_hash: String,
pub schema_version: String,
#[serde(default)]
pub synthetic: bool,
}
impl LockEntry {
#[must_use]
pub fn new(
id: impl Into<String>,
sha: impl Into<String>,
branch: impl Into<String>,
installed_at: DateTime<Utc>,
actions_hash: impl Into<String>,
schema_version: impl Into<String>,
) -> Self {
Self {
id: id.into(),
sha: sha.into(),
branch: branch.into(),
installed_at,
actions_hash: actions_hash.into(),
schema_version: schema_version.into(),
synthetic: false,
}
}
}
#[derive(Debug, Error)]
pub enum LockfileError {
#[error("lockfile i/o error: {0}")]
Io(#[from] std::io::Error),
#[error("lockfile corrupted at line {line}: {source}")]
Corruption {
line: usize,
#[source]
source: serde_json::Error,
},
#[error("lockfile serialize error: {0}")]
Serialize(serde_json::Error),
}