Skip to content
This repository has been archived by the owner on Aug 16, 2023. It is now read-only.

Commit

Permalink
Fix clippy
Browse files Browse the repository at this point in the history
  • Loading branch information
0nkery committed Nov 7, 2022
1 parent ce2281b commit 5e64aef
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 14 deletions.
15 changes: 3 additions & 12 deletions src/db/event/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -118,10 +118,10 @@ pub(crate) struct RawObject {
removed: bool,
}

pub type EventData = (Uuid, Option<JsonValue>, Option<PostcardBin<CompactEvent>>);

impl RawObject {
pub fn encode_to_binary(
&self,
) -> Result<(Uuid, Option<JsonValue>, Option<PostcardBin<CompactEvent>>), anyhow::Error> {
pub fn encode_to_binary(&self) -> Result<EventData, anyhow::Error> {
let r = match self.data.as_ref() {
Some(data) => (
self.id,
Expand All @@ -134,15 +134,6 @@ impl RawObject {
Ok(r)
}

pub fn decode_from_binary(&self) -> Result<(Uuid, Option<JsonValue>), 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()
}
Expand Down
4 changes: 2 additions & 2 deletions src/migration_to_binary_format.rs
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ async fn do_migrate_to_binary(db: Db, stop: Arc<AtomicBool>) -> 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);
Expand Down Expand Up @@ -295,7 +295,7 @@ async fn do_migrate_to_json(db: Db, dir: String, stop: Arc<AtomicBool>) -> 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;
}

Expand Down

0 comments on commit 5e64aef

Please sign in to comment.