forbid unsafe/undoc'd

This commit is contained in:
Stephan Dilly 2020-03-24 22:21:53 +01:00
parent e557be6de0
commit 96b2b30052
6 changed files with 37 additions and 3 deletions

View file

@ -11,6 +11,7 @@ struct DiffRequest(String, bool);
struct Request<R, A>(R, Option<A>);
///
pub struct AsyncDiff {
current: Arc<Mutex<Request<u64, Diff>>>,
sender: Sender<AsyncNotification>,

View file

@ -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<T: 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)

View file

@ -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<DiffLine>);
///

View file

@ -1,3 +1,5 @@
//! sync git api
pub mod diff;
pub mod status;
pub mod utils;

View file

@ -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<Status> for StatusItemType {
///
#[derive(Default, Clone, Hash)]
pub struct StatusItem {
///
pub path: String,
///
pub status: Option<StatusItemType>,
}
///
#[derive(Copy, Clone)]
pub enum StatusType {
///
WorkingDir,
///
Stage,
}

View file

@ -1,3 +1,5 @@
//! sync git api (various methods)
use git2::{
build::CheckoutBuilder, IndexAddOption, ObjectType, Repository,
RepositoryOpenFlags,