my fork of dmp
Diffstat (limited to 'src/patch_input.rs')
-rw-r--r--src/patch_input.rs21
1 files changed, 21 insertions, 0 deletions
diff --git a/src/patch_input.rs b/src/patch_input.rs
new file mode 100644
index 0000000..824bfc8
--- /dev/null
+++ b/src/patch_input.rs
@@ -0,0 +1,21 @@
+use crate::{dmp::Diff, DType};
+
+pub enum PatchInput<'a, T: DType> {
+ Texts(&'a str, &'a str),
+ Diffs(&'a [Diff<T>]),
+ TextDiffs(&'a str, &'a [Diff<T>]),
+}
+
+impl<'a, T: DType> PatchInput<'a, T> {
+ pub fn new_text_text(old: &'a str, new: &'a str) -> Self {
+ Self::Texts(old, new)
+ }
+
+ pub fn new_diffs(diffs: &'a [Diff<T>]) -> Self {
+ Self::Diffs(diffs)
+ }
+
+ pub fn new_text_diffs(old: &'a str, diffs: &'a [Diff<T>]) -> Self {
+ Self::TextDiffs(old, diffs)
+ }
+}