Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove identity-diff remains #1195

Merged
merged 1 commit into from
Jun 30, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 0 additions & 33 deletions identity_core/src/common/one_or_set.rs
Original file line number Diff line number Diff line change
Expand Up @@ -316,39 +316,6 @@ where
}
}

#[cfg(feature = "diff")]
mod diff {
use super::*;
use identity_diff::Diff;
use identity_diff::DiffVec;
impl<T> Diff for OneOrSet<T>
where
T: Diff + KeyComparable + Serialize + for<'de> Deserialize<'de>,
{
type Type = DiffVec<T>;

fn diff(&self, other: &Self) -> identity_diff::Result<Self::Type> {
self.clone().into_vec().diff(&other.clone().into_vec())
}

fn merge(&self, diff: Self::Type) -> identity_diff::Result<Self> {
self
.clone()
.into_vec()
.merge(diff)
.and_then(|this| Self::try_from(this).map_err(identity_diff::Error::merge))
}

fn from_diff(diff: Self::Type) -> identity_diff::Result<Self> {
Vec::from_diff(diff).and_then(|this| Self::try_from(this).map_err(identity_diff::Error::convert))
}

fn into_diff(self) -> identity_diff::Result<Self::Type> {
self.into_vec().into_diff()
}
}
}

#[cfg(test)]
mod tests {
use crate::convert::FromJson;
Expand Down
33 changes: 0 additions & 33 deletions identity_core/src/common/ordered_set.rs
Original file line number Diff line number Diff line change
Expand Up @@ -285,39 +285,6 @@ where
}
}

#[cfg(feature = "diff")]
mod diff {
use super::*;
use identity_diff::Diff;
use identity_diff::DiffVec;
impl<T> Diff for OrderedSet<T>
where
T: Diff + KeyComparable + Serialize + for<'de> Deserialize<'de>,
{
type Type = DiffVec<T>;

fn diff(&self, other: &Self) -> identity_diff::Result<Self::Type> {
self.clone().into_vec().diff(&other.clone().into_vec())
}

fn merge(&self, diff: Self::Type) -> identity_diff::Result<Self> {
self
.clone()
.into_vec()
.merge(diff)
.and_then(|this| Self::try_from(this).map_err(identity_diff::Error::merge))
}

fn from_diff(diff: Self::Type) -> identity_diff::Result<Self> {
Vec::from_diff(diff).and_then(|this| Self::try_from(this).map_err(identity_diff::Error::convert))
}

fn into_diff(self) -> identity_diff::Result<Self::Type> {
self.into_vec().into_diff()
}
}
}

#[cfg(test)]
mod tests {
use std::collections::HashSet;
Expand Down
57 changes: 0 additions & 57 deletions identity_core/src/common/timestamp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -175,38 +175,6 @@ fn truncate_fractional_seconds(offset_date_time: OffsetDateTime) -> OffsetDateTi
offset_date_time - time::Duration::nanoseconds(offset_date_time.nanosecond() as i64)
}

#[cfg(feature = "diff")]
mod diff {
use super::*;
use identity_diff::Diff;
use identity_diff::DiffString;

use crate::diff;

impl Diff for Timestamp {
type Type = DiffString;

fn diff(&self, other: &Self) -> diff::Result<Self::Type> {
self.to_string().diff(&other.to_string())
}

fn merge(&self, diff: Self::Type) -> diff::Result<Self> {
self
.to_string()
.merge(diff)
.and_then(|this| Self::parse(&this).map_err(diff::Error::merge))
}

fn from_diff(diff: Self::Type) -> diff::Result<Self> {
String::from_diff(diff).and_then(|this| Self::parse(&this).map_err(diff::Error::convert))
}

fn into_diff(self) -> diff::Result<Self::Type> {
self.to_string().into_diff()
}
}
}

/// A span of time.
///
/// This type is typically used to increment or decrement a [`Timestamp`].
Expand Down Expand Up @@ -395,29 +363,4 @@ mod tests {

assert_eq!(time1, time2);
}

#[cfg(feature = "diff")]
#[test]
fn test_timestamp_diff() {
use identity_diff::Diff;
use identity_diff::DiffString;
let time1: Timestamp = Timestamp::parse("2021-01-01T12:00:01Z").unwrap();
let time2: Timestamp = Timestamp::parse("2022-01-02T12:00:02Z").unwrap();

// Diff
let non_diff: DiffString = time1.diff(&time1).unwrap();
assert!(non_diff.0.is_none());
let diff12: DiffString = time1.diff(&time2).unwrap();
assert_eq!(String::from_diff(diff12.clone()).unwrap(), time2.to_string());
let diff21: DiffString = time2.diff(&time1).unwrap();
assert_eq!(String::from_diff(diff21.clone()).unwrap(), time1.to_string());

// Merge
assert_eq!(time1.merge(non_diff.clone()).unwrap(), time1);
assert_eq!(time2.merge(non_diff).unwrap(), time2);
assert_eq!(time1.merge(diff12.clone()).unwrap(), time2);
assert_eq!(time1.merge(diff21.clone()).unwrap(), time1);
assert_eq!(time2.merge(diff12).unwrap(), time2);
assert_eq!(time2.merge(diff21).unwrap(), time1);
}
}
30 changes: 0 additions & 30 deletions identity_core/src/common/url.rs
Original file line number Diff line number Diff line change
Expand Up @@ -88,36 +88,6 @@ where
}
}

#[cfg(feature = "diff")]
mod diff {
use super::*;
use crate::diff;
use crate::diff::Diff;
use crate::diff::DiffString;
impl Diff for Url {
type Type = DiffString;

fn diff(&self, other: &Self) -> diff::Result<Self::Type> {
self.to_string().diff(&other.to_string())
}

fn merge(&self, diff: Self::Type) -> diff::Result<Self> {
self
.to_string()
.merge(diff)
.and_then(|this| Self::parse(this).map_err(diff::Error::merge))
}

fn from_diff(diff: Self::Type) -> diff::Result<Self> {
String::from_diff(diff).and_then(|this| Self::parse(this).map_err(diff::Error::convert))
}

fn into_diff(self) -> diff::Result<Self::Type> {
self.to_string().into_diff()
}
}
}

impl KeyComparable for Url {
type Key = Url;

Expand Down
5 changes: 0 additions & 5 deletions identity_core/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,6 @@ pub enum Error {
/// Caused by a failure to decode multibase-encoded data.
#[error("failed to decode multibase data")]
DecodeMultibase(#[from] multibase::Error),
#[cfg(feature = "diff")]
/// Caused by attempting to perform an invalid `Diff` operation.
#[deprecated(since = "0.5.0", note = "diff chain features are slated for removal")]
#[error("invalid document diff")]
InvalidDiff(#[from] identity_diff::Error),
/// Caused by attempting to parse an invalid `Url`.
#[error("invalid url")]
InvalidUrl(#[from] url::ParseError),
Expand Down
5 changes: 0 additions & 5 deletions identity_core/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,6 @@
#[doc(inline)]
pub use serde_json::json;

#[cfg(feature = "diff")]
#[deprecated(since = "0.5.0", note = "diff chain features are slated for removal")]
#[doc(inline)]
pub use identity_diff as diff;

pub mod common;
pub mod convert;
pub mod crypto;
Expand Down
29 changes: 0 additions & 29 deletions identity_did/src/did.rs
Original file line number Diff line number Diff line change
Expand Up @@ -237,35 +237,6 @@ impl From<CoreDID> for String {
}
}

#[cfg(feature = "diff")]
mod diff {
use super::*;
use identity_core::diff::Diff;
use identity_core::diff::DiffString;
impl Diff for CoreDID {
type Type = DiffString;

fn diff(&self, other: &Self) -> identity_core::diff::Result<Self::Type> {
self.to_string().diff(&other.to_string())
}

fn merge(&self, diff: Self::Type) -> identity_core::diff::Result<Self> {
self
.to_string()
.merge(diff)
.and_then(|this| Self::parse(this).map_err(identity_core::diff::Error::merge))
}

fn from_diff(diff: Self::Type) -> identity_core::diff::Result<Self> {
String::from_diff(diff).and_then(|this| Self::parse(this).map_err(identity_core::diff::Error::convert))
}

fn into_diff(self) -> identity_core::diff::Result<Self::Type> {
self.to_string().into_diff()
}
}
}

impl PartialEq<str> for CoreDID {
fn eq(&self, other: &str) -> bool {
self.as_str() == other
Expand Down
29 changes: 0 additions & 29 deletions identity_did/src/did_url.rs
Original file line number Diff line number Diff line change
Expand Up @@ -515,35 +515,6 @@ impl Display for DIDUrl {
}
}

#[cfg(feature = "diff")]
mod diff {
use super::*;
use identity_core::diff::Diff;
use identity_core::diff::DiffString;
impl Diff for DIDUrl {
type Type = DiffString;

fn diff(&self, other: &Self) -> identity_core::diff::Result<Self::Type> {
self.to_string().diff(&other.to_string())
}

fn merge(&self, diff: Self::Type) -> identity_core::diff::Result<Self> {
self
.to_string()
.merge(diff)
.and_then(|this| Self::parse(this).map_err(identity_core::diff::Error::merge))
}

fn from_diff(diff: Self::Type) -> identity_core::diff::Result<Self> {
String::from_diff(diff).and_then(|this| Self::parse(this).map_err(identity_core::diff::Error::convert))
}

fn into_diff(self) -> identity_core::diff::Result<Self::Type> {
self.to_string().into_diff()
}
}
}

impl KeyComparable for DIDUrl {
type Key = Self;

Expand Down
Loading