/
lib.rs
57 lines (49 loc) · 1.41 KB
/
lib.rs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
//! Parse [ref specs]() and represent them.
#![forbid(unsafe_code, rust_2018_idioms)]
#![allow(missing_docs)]
pub mod parse;
pub use parse::function::parse;
/// A refspec with references to the memory it was parsed from.
#[derive(PartialEq, Eq, Copy, Clone, Hash, Debug)]
pub struct RefSpecRef<'a> {
mode: Mode,
op: Operation,
src: Option<&'a bstr::BStr>,
dest: Option<&'a bstr::BStr>,
}
/// An owned refspec.
#[derive(PartialEq, Eq, Clone, Hash, Debug)]
pub struct RefSpec {
mode: Mode,
op: Operation,
src: Option<bstr::BString>,
dest: Option<bstr::BString>,
}
mod types;
pub use types::{Instruction, Mode, Operation};
mod spec {
use crate::{Instruction, Mode, RefSpec, RefSpecRef};
/// Access
impl RefSpecRef<'_> {
/// Return the refspec mode.
pub fn mode(&self) -> Mode {
self.mode
}
/// Transform the state of the refspec into an instruction making clear what to do with it.
pub fn instruction(&self) -> Instruction<'_> {
todo!()
}
}
/// Conversion
impl RefSpecRef<'_> {
/// Convert this ref into a standalone, owned copy.
pub fn to_owned(&self) -> RefSpec {
RefSpec {
mode: self.mode,
op: self.op,
src: self.src.map(ToOwned::to_owned),
dest: self.dest.map(ToOwned::to_owned),
}
}
}
}