my fork of dmp
Diffstat (limited to 'src/dmp.rs')
-rw-r--r--src/dmp.rs7
1 files changed, 4 insertions, 3 deletions
diff --git a/src/dmp.rs b/src/dmp.rs
index 1258d8d..3e9f0dc 100644
--- a/src/dmp.rs
+++ b/src/dmp.rs
@@ -3,6 +3,7 @@ use std::{char, collections::HashMap, fmt::Display};
#[cfg(target_arch = "wasm32")]
use chrono::{NaiveTime, TimeDelta, Utc};
+use serde_derive::{Deserialize, Serialize};
#[cfg(not(target_arch = "wasm32"))]
use std::time::{Duration, Instant};
@@ -14,7 +15,7 @@ pub(crate) type Time = Instant;
use crate::{errors::Error, html::HtmlConfig, DType, PatchInput};
/// Enum representing the different ops of diff
-#[derive(Debug, PartialEq, Eq, Clone, Copy)]
+#[derive(Debug, PartialEq, Eq, Clone, Copy, Serialize, Deserialize)]
pub enum Ops {
Delete = -1,
Equal,
@@ -25,7 +26,7 @@ pub enum Ops {
/// (Ops::Delete, String::new("Hello")) means delete `Hello`
/// (Ops::Insert, String::new("Goodbye")) means add `Goodbye`
/// (Ops::Equal, String::new("World")) means keep world
-#[derive(Debug, Clone, PartialEq, Eq)]
+#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
pub struct Diff<T: DType>(pub(crate) Ops, pub(crate) Vec<T>);
impl Display for Diff<u8> {
@@ -2317,7 +2318,7 @@ impl DiffMatchPatch {
}
// Patch Methods
-#[derive(Debug, Clone)]
+#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct Patch<T: DType> {
diffs: Vec<Diff<T>>,
start1: usize,