my fork of dmp
serde
| -rw-r--r-- | Cargo.toml | 8 | ||||
| -rw-r--r-- | src/dmp.rs | 7 |
2 files changed, 9 insertions, 6 deletions
@@ -3,7 +3,7 @@ name = "diff-match-patch-rs" version = "0.5.1" edition = "2021" authors = ["Anubhab Bandyopadhyay"] -homepage = "https://docs.rs/diff-match-patch-rs" +homepage = "https://docs.rs/diff-match-patch-rs" repository = "https://github.com/AnubhabB/diff-match-patch-rs.git" description = "The fastest implementation of Myer's diff algorithm to perform the operations required for synchronizing plain text." readme = "README.md" @@ -13,6 +13,8 @@ categories = ["algorithms", "text-processing", "text-editors", "wasm"] [dependencies] percent-encoding = "2" +serde = "1.0.228" +serde_derive = "1.0.228" [target.wasm32-unknown-unknown.dependencies] chrono = "0" @@ -23,7 +25,7 @@ targets = [ "aarch64-apple-darwin", "x86_64-unknown-linux-gnu", "x86_64-apple-darwin", - "wasm32-unknown-unknown" + "wasm32-unknown-unknown", ] rustdoc-args = ["--generate-link-to-definition"] @@ -31,4 +33,4 @@ rustdoc-args = ["--generate-link-to-definition"] name = "efficiency" [[example]] -name = "compat"
\ No newline at end of file +name = "compat" @@ -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, |