diff --git a/src/db/event/mod.rs b/src/db/event/mod.rs index b69edc79..acdc5f18 100644 --- a/src/db/event/mod.rs +++ b/src/db/event/mod.rs @@ -118,10 +118,10 @@ pub(crate) struct RawObject { removed: bool, } +pub type EventData = (Uuid, Option, Option>); + impl RawObject { - pub fn encode_to_binary( - &self, - ) -> Result<(Uuid, Option, Option>), anyhow::Error> { + pub fn encode_to_binary(&self) -> Result { let r = match self.data.as_ref() { Some(data) => ( self.id, @@ -134,15 +134,6 @@ impl RawObject { Ok(r) } - pub fn decode_from_binary(&self) -> Result<(Uuid, Option), anyhow::Error> { - let r = match self.binary_data.as_ref() { - Some(binary) => (self.id, Some(binary.clone().into_inner().into_json()?)), - None => (self.id, None), - }; - - Ok(r) - } - pub fn data(&self) -> Option<&JsonValue> { self.data.as_ref() } diff --git a/src/migration_to_binary_format.rs b/src/migration_to_binary_format.rs index 2065c604..e8adf283 100644 --- a/src/migration_to_binary_format.rs +++ b/src/migration_to_binary_format.rs @@ -167,7 +167,7 @@ async fn do_migrate_to_binary(db: Db, stop: Arc) -> Result<()> { Ok(binary_data) => { let evt_data = serde_json::to_vec(&Event { data, id })?; file.write_all(&evt_data).await?; - file.write(b"\n").await?; + file.write_all(b"\n").await?; event_ids.push(id); event_binary_data.push(binary_data); @@ -295,7 +295,7 @@ async fn do_migrate_to_json(db: Db, dir: String, stop: Arc) -> Resul Some(room_id) => room_id, None => continue, }; - if let Err(_) = Uuid::from_str(room_id) { + if Uuid::from_str(room_id).is_err() { continue; }