diff --git a/Cargo.toml b/Cargo.toml index 8623837b..2c44e313 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -41,6 +41,7 @@ features = ["client-api", "federation-api", "appservice-api", "unstable-pre-spec [features] default = ["unstable-pre-spec"] +gen-eventid = [] unstable-pre-spec = ["ruma/unstable-pre-spec"] [dev-dependencies] diff --git a/src/state_event.rs b/src/state_event.rs index afa1ba3c..330143d8 100644 --- a/src/state_event.rs +++ b/src/state_event.rs @@ -92,18 +92,18 @@ impl<'de> de::Deserialize<'de> for StateEvent { } } -// #[cfg(not(test))] -// fn event_id(json: &RawJsonValue) -> Result { -// use std::convert::TryFrom; -// EventId::try_from(format!( -// "${}", -// reference_hash(&from_raw_json_value(&json)?, &RoomVersionId::Version6) -// .map_err(de::Error::custom)?, -// )) -// .map_err(de::Error::custom) -// } +#[cfg(feature = "gen-eventid")] +fn event_id(json: &RawJsonValue) -> Result { + use std::convert::TryFrom; + EventId::try_from(format!( + "${}", + reference_hash(&from_raw_json_value(&json)?, &RoomVersionId::Version6) + .map_err(de::Error::custom)?, + )) + .map_err(de::Error::custom) +} -// #[cfg(test)] +#[cfg(not(feature = "gen-eventid"))] fn event_id(json: &RawJsonValue) -> Result { use std::convert::TryFrom; Ok(match from_raw_json_value::(&json) {