use schemars::JsonSchema;
use serde::Serialize;
#[derive(Debug, Serialize, JsonSchema)]
pub struct WriteOutput {
pub r#type: &'static str,
pub status: &'static str,
pub path: String,
pub bytes_written: u64,
pub checksum: String,
#[serde(skip_serializing_if = "Option::is_none")]
pub checksum_before: Option<String>,
#[serde(skip_serializing_if = "Option::is_none")]
pub backup_path: Option<String>,
pub elapsed_ms: u64,
pub platform: PlatformInfo,
}
#[derive(Debug, Serialize, JsonSchema)]
pub struct PlatformInfo {
pub fsync: &'static str,
pub dir_fsync: &'static str,
}
#[derive(Debug, Serialize, JsonSchema)]
pub struct ReadOutput {
pub r#type: &'static str,
pub path: String,
#[serde(skip_serializing_if = "Option::is_none")]
pub content: Option<String>,
pub lines: u64,
pub bytes: u64,
pub checksum: String,
pub permissions: String,
pub modified: String,
pub kind: String,
pub binary: bool,
#[serde(skip_serializing_if = "Option::is_none")]
pub range: Option<LineRange>,
#[serde(skip_serializing_if = "Option::is_none")]
pub verified: Option<bool>,
}
#[derive(Debug, Serialize, JsonSchema)]
pub struct LineRange {
pub start: usize,
pub end: usize,
}
#[derive(Debug, Serialize, JsonSchema)]
pub struct SearchBegin {
pub r#type: &'static str,
pub path: String,
}
#[derive(Debug, Serialize, JsonSchema)]
pub struct SearchMatch {
pub r#type: &'static str,
pub path: String,
pub line_number: u64,
pub lines: String,
pub byte_offset: u64,
#[serde(skip_serializing_if = "Vec::is_empty")]
pub submatches: Vec<Submatch>,
}
#[derive(Debug, Serialize, JsonSchema)]
pub struct Submatch {
pub r#match: String,
pub start: usize,
pub end: usize,
}
#[derive(Debug, Serialize, JsonSchema)]
pub struct SearchContext {
pub r#type: &'static str,
pub path: String,
pub line_number: u64,
pub lines: String,
}
#[derive(Debug, Serialize, JsonSchema)]
pub struct SearchEnd {
pub r#type: &'static str,
pub path: String,
pub stats: FileStats,
}
#[derive(Debug, Serialize, JsonSchema)]
pub struct FileStats {
pub matches: u64,
pub lines_searched: u64,
}
#[derive(Debug, Serialize, JsonSchema)]
pub struct SearchCount {
pub r#type: &'static str,
pub path: String,
pub count: u64,
}
#[derive(Debug, Serialize, JsonSchema)]
pub struct SearchFile {
pub r#type: &'static str,
pub path: String,
}
#[derive(Debug, Serialize, JsonSchema)]
pub struct Summary {
pub r#type: &'static str,
pub files_visited: u64,
pub files_matched: u64,
#[serde(skip_serializing_if = "Option::is_none")]
pub files_modified: Option<u64>,
#[serde(skip_serializing_if = "Option::is_none")]
pub files_skipped: Option<u64>,
#[serde(skip_serializing_if = "Option::is_none")]
pub total_matches: Option<u64>,
#[serde(skip_serializing_if = "Option::is_none")]
pub total_replacements: Option<u64>,
pub elapsed_ms: u64,
}
#[derive(Debug, Serialize, JsonSchema)]
pub struct ReplaceResult {
pub r#type: &'static str,
pub path: String,
pub replacements: u64,
pub bytes_before: u64,
pub bytes_after: u64,
pub checksum_before: String,
pub checksum_after: String,
pub elapsed_ms: u64,
}
#[derive(Debug, Serialize, JsonSchema)]
pub struct EditOutput {
pub r#type: &'static str,
pub path: String,
pub edits: u64,
pub mode: String,
pub bytes_before: u64,
pub bytes_after: u64,
pub checksum_before: String,
pub checksum_after: String,
pub lines_before: u64,
pub lines_after: u64,
pub elapsed_ms: u64,
#[serde(skip_serializing_if = "Option::is_none")]
pub fuzzy: Option<bool>,
#[serde(skip_serializing_if = "Option::is_none")]
pub strategy: Option<String>,
#[serde(skip_serializing_if = "Option::is_none")]
pub strategies_tried: Option<u64>,
#[serde(skip_serializing_if = "Option::is_none")]
pub similarity: Option<f64>,
}
#[derive(Debug, Serialize, JsonSchema)]
pub struct DryRunPlan {
pub r#type: &'static str,
pub operation: String,
pub path: String,
pub would_modify: bool,
#[serde(skip_serializing_if = "Option::is_none")]
pub details: Option<String>,
}
#[derive(Debug, Serialize, JsonSchema)]
pub struct ListEntry {
pub r#type: &'static str,
pub path: String,
pub kind: String,
#[serde(skip_serializing_if = "Option::is_none")]
pub size: Option<u64>,
#[serde(skip_serializing_if = "Option::is_none")]
pub modified: Option<String>,
}
#[derive(Debug, Serialize, JsonSchema)]
pub struct ListSummary {
pub r#type: &'static str,
pub files: u64,
pub dirs: u64,
pub symlinks: u64,
#[serde(skip_serializing_if = "Option::is_none")]
pub total_bytes: Option<u64>,
#[serde(skip_serializing_if = "Option::is_none")]
pub by_extension: Option<std::collections::BTreeMap<String, u64>>,
pub elapsed_ms: u64,
}
#[derive(Debug, Serialize, JsonSchema)]
pub struct CalcOutput {
pub r#type: &'static str,
pub expression: String,
pub result: String,
pub elapsed_ms: u64,
}
#[derive(Debug, Serialize, JsonSchema)]
pub struct RegexOutput {
pub r#type: &'static str,
pub regex: String,
pub examples: u64,
pub anchored: bool,
pub elapsed_ms: u64,
}
#[derive(Debug, Serialize, JsonSchema)]
pub struct TransformResult {
pub r#type: &'static str,
pub path: String,
pub language: String,
pub matches: u64,
pub replacements: u64,
pub bytes_before: u64,
pub bytes_after: u64,
pub checksum_before: String,
pub checksum_after: String,
pub elapsed_ms: u64,
}
#[derive(Debug, Serialize, JsonSchema)]
pub struct ScopeResult {
pub r#type: &'static str,
pub path: String,
pub language: String,
pub query: String,
pub action: String,
pub scopes_matched: u64,
pub bytes_before: u64,
pub bytes_after: u64,
pub checksum_before: String,
pub checksum_after: String,
pub elapsed_ms: u64,
}
#[derive(Debug, Serialize, JsonSchema)]
pub struct BackupResult {
pub r#type: &'static str,
pub path: String,
pub backup_path: String,
pub checksum: String,
pub bytes: u64,
pub elapsed_ms: u64,
}
#[derive(Debug, Serialize, JsonSchema)]
pub struct RollbackResult {
pub r#type: &'static str,
pub path: String,
pub restored_from: String,
pub checksum_before: Option<String>,
pub checksum_after: String,
#[serde(skip_serializing_if = "Option::is_none")]
pub verified: Option<bool>,
pub elapsed_ms: u64,
}
#[derive(Debug, Serialize, JsonSchema)]
pub struct ApplyResult {
pub r#type: &'static str,
pub path: String,
pub format_detected: String,
pub hunks_applied: u64,
pub bytes_before: u64,
pub bytes_after: u64,
pub checksum_before: String,
pub checksum_after: String,
pub elapsed_ms: u64,
}
#[derive(Debug, Serialize, JsonSchema)]
pub struct BatchOpResult<'a> {
pub r#type: &'static str,
pub index: u64,
pub op: &'a str,
pub status: &'static str,
#[serde(skip_serializing_if = "Option::is_none")]
pub details: Option<String>,
#[serde(skip_serializing_if = "Option::is_none")]
pub error: Option<String>,
pub elapsed_ms: u64,
}
#[derive(Debug, Serialize, JsonSchema)]
pub struct BatchSummary {
pub r#type: &'static str,
pub operations: u64,
pub succeeded: u64,
pub failed: u64,
pub dry_run: bool,
pub elapsed_ms: u64,
#[serde(skip_serializing_if = "Option::is_none")]
pub transaction: Option<bool>,
#[serde(skip_serializing_if = "Option::is_none")]
pub committed: Option<bool>,
}