| use serde::{Deserialize, Serialize}; |
|
|
| #[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)] |
| pub struct File { |
| pub path: String, |
| pub is_dir: bool, |
| } |
|
|
| |
| #[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)] |
| pub struct FileInfo { |
| |
| pub start_line: u64, |
|
|
| |
| pub end_line: u64, |
|
|
| |
| pub total_lines: u64, |
|
|
| |
| |
| |
| pub content_hash: String, |
| } |
|
|
| impl FileInfo { |
| |
| pub fn new(start_line: u64, end_line: u64, total_lines: u64, content_hash: String) -> Self { |
| Self { start_line, end_line, total_lines, content_hash } |
| } |
|
|
| |
| pub fn is_partial(&self) -> bool { |
| self.start_line > 0 || self.end_line < self.total_lines |
| } |
| } |
|
|
| |
| |
| |
| #[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)] |
| pub struct FileHash { |
| |
| pub path: String, |
| |
| pub hash: String, |
| } |
|
|
| impl From<super::node::FileNode> for FileHash { |
| fn from(node: super::node::FileNode) -> Self { |
| Self { path: node.file_path, hash: node.hash } |
| } |
| } |
|
|
| |
| #[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize, PartialOrd, Ord)] |
| pub enum SyncStatus { |
| |
| InSync, |
| |
| Modified, |
| |
| New, |
| |
| Deleted, |
| |
| Failed, |
| } |
|
|
| |
| #[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)] |
| pub struct FileStatus { |
| |
| pub path: String, |
| |
| pub status: SyncStatus, |
| } |
|
|
| impl FileStatus { |
| |
| pub fn new(path: String, status: SyncStatus) -> Self { |
| Self { path, status } |
| } |
| } |
|
|