#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq, Ord, PartialOrd)]
pub struct ContextSize {
symmetrical: u32,
}
impl Default for ContextSize {
fn default() -> Self {
ContextSize::symmetrical(3)
}
}
impl ContextSize {
pub fn symmetrical(n: u32) -> Self {
ContextSize { symmetrical: n }
}
}
#[doc(alias = "git2")]
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Ord, PartialOrd)]
pub enum DiffLineKind {
Context,
Add,
Remove,
}
#[derive(Default, Debug, Copy, Clone, PartialEq, Eq, Hash, Ord, PartialOrd)]
pub struct HunkHeader {
pub before_hunk_start: u32,
pub before_hunk_len: u32,
pub after_hunk_start: u32,
pub after_hunk_len: u32,
}
pub struct ConsumeBinaryHunk<'a, D> {
pub newline: &'a str,
pub delegate: D,
header_buf: String,
hunk_buf: Vec<u8>,
}
pub trait ConsumeBinaryHunkDelegate {
fn consume_binary_hunk(&mut self, header: HunkHeader, header_str: &str, hunk: &[u8]) -> std::io::Result<()>;
}
pub trait ConsumeHunk {
type Out;
fn consume_hunk(&mut self, header: HunkHeader, lines: &[(DiffLineKind, &[u8])]) -> std::io::Result<()>;
fn finish(self) -> Self::Out;
}
pub(super) mod impls;