diff --git a/asyncgit/src/diff.rs b/asyncgit/src/diff.rs index eae7bee4..6a7c4738 100644 --- a/asyncgit/src/diff.rs +++ b/asyncgit/src/diff.rs @@ -11,6 +11,7 @@ struct DiffRequest(String, bool); struct Request(R, Option); +/// pub struct AsyncDiff { current: Arc>>, sender: Sender, diff --git a/asyncgit/src/lib.rs b/asyncgit/src/lib.rs index 814f542c..44e18d30 100644 --- a/asyncgit/src/lib.rs +++ b/asyncgit/src/lib.rs @@ -1,3 +1,7 @@ +//! asyncgit + +#![forbid(unsafe_code)] +#![warn(missing_docs)] mod diff; mod status; pub mod sync; @@ -16,18 +20,23 @@ use std::{ time::{SystemTime, UNIX_EPOCH}, }; +/// this type is used to communicate events back through the channel #[derive(Copy, Clone, Debug)] pub enum AsyncNotification { + /// Status, + /// Diff, } +/// helper function to calculate the hash of an arbitrary type that implements the `Hash` trait pub fn hash(v: &T) -> u64 { let mut hasher = DefaultHasher::new(); v.hash(&mut hasher); hasher.finish() } +/// helper function to return the current tick since unix epoch pub fn current_tick() -> u64 { SystemTime::now() .duration_since(UNIX_EPOCH) diff --git a/asyncgit/src/sync/diff.rs b/asyncgit/src/sync/diff.rs index 706798fa..5375673b 100644 --- a/asyncgit/src/sync/diff.rs +++ b/asyncgit/src/sync/diff.rs @@ -1,14 +1,20 @@ +//! sync git api for fetching a diff + use super::utils; use git2::{Delta, DiffDelta, DiffFormat, DiffOptions, Patch}; use scopetime::scope_time; use std::fs; /// -#[derive(Copy, Clone, PartialEq)] +#[derive(Copy, Clone, PartialEq, Hash)] pub enum DiffLineType { + /// None, + /// Header, + /// Add, + /// Delete, } @@ -19,14 +25,16 @@ impl Default for DiffLineType { } /// -#[derive(Default, PartialEq, Clone)] +#[derive(Default, Clone, Hash)] pub struct DiffLine { + /// pub content: String, + /// pub line_type: DiffLineType, } /// -#[derive(Default, PartialEq, Clone)] +#[derive(Default, Clone, Hash)] pub struct Diff(pub Vec); /// diff --git a/asyncgit/src/sync/mod.rs b/asyncgit/src/sync/mod.rs index 18c19ab0..f3b9179d 100644 --- a/asyncgit/src/sync/mod.rs +++ b/asyncgit/src/sync/mod.rs @@ -1,3 +1,5 @@ +//! sync git api + pub mod diff; pub mod status; pub mod utils; diff --git a/asyncgit/src/sync/status.rs b/asyncgit/src/sync/status.rs index e4b15d61..41b5caa7 100644 --- a/asyncgit/src/sync/status.rs +++ b/asyncgit/src/sync/status.rs @@ -1,13 +1,21 @@ +//! sync git api for fetching a status + use crate::sync::utils; use git2::{Status, StatusOptions, StatusShow}; use scopetime::scope_time; +/// #[derive(Copy, Clone, Hash)] pub enum StatusItemType { + /// New, + /// Modified, + /// Deleted, + /// Renamed, + /// Typechange, } @@ -30,14 +38,18 @@ impl From for StatusItemType { /// #[derive(Default, Clone, Hash)] pub struct StatusItem { + /// pub path: String, + /// pub status: Option, } /// #[derive(Copy, Clone)] pub enum StatusType { + /// WorkingDir, + /// Stage, } diff --git a/asyncgit/src/sync/utils.rs b/asyncgit/src/sync/utils.rs index 3d8117be..1c078234 100644 --- a/asyncgit/src/sync/utils.rs +++ b/asyncgit/src/sync/utils.rs @@ -1,3 +1,5 @@ +//! sync git api (various methods) + use git2::{ build::CheckoutBuilder, IndexAddOption, ObjectType, Repository, RepositoryOpenFlags,