Skip to content

Commit

Permalink
fix get contact by id
Browse files Browse the repository at this point in the history
  • Loading branch information
nanu-c committed Jan 10, 2023
1 parent f98e541 commit 6b29208
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
2 changes: 2 additions & 0 deletions src/errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,8 @@ pub enum Error {
MigrationConflict,
#[error("I/O error: {0}")]
FsError(#[from] fs_extra::error::Error),
#[error("Could not find a contact with the given UUID")]
ContactNotFound
}

impl Error {
Expand Down
5 changes: 2 additions & 3 deletions src/store/sled.rs
Original file line number Diff line number Diff line change
Expand Up @@ -355,9 +355,8 @@ impl ContactsStore for SledStore {

fn contact_by_id(&self, id: Uuid) -> Result<Option<Contact>, Error> {
self.get(SLED_KEY_CONTACTS, id)?
.map(|b: Vec<u8>| serde_json::from_slice(&b))
.transpose()
.map_err(Error::from)
.map(|contact: Contact| Some(contact))
.ok_or(Error::ContactNotFound)
}
}

Expand Down

0 comments on commit 6b29208

Please sign in to comment.