Skip to content

Commit

Permalink
refactor: AFIT & RPITIT
Browse files Browse the repository at this point in the history
  • Loading branch information
fundon committed Jan 2, 2024
1 parent cf9e76c commit 5aef7f8
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions sessions-core/src/session.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ impl Session {
match self
.lock_data()
.read()
.map_err(|e| Error::new(ErrorKind::Other, e.to_string()))?
.map_err(into_io_error)?
.get(key)
.cloned()
{
Expand All @@ -70,7 +70,7 @@ impl Session {
}
d.insert(
key.into(),
serde_json::to_value(val).map_err(|e| Error::new(ErrorKind::Other, e))?,
serde_json::to_value(val).map_err(into_io_error)?,
);
}
}
Expand Down Expand Up @@ -141,7 +141,7 @@ impl Session {
pub fn data(&self) -> Result<Data> {
self.lock_data()
.read()
.map_err(|e| Error::new(ErrorKind::Other, e.to_string()))
.map_err(into_io_error)
.map(|d| d.clone())
}
}
Expand All @@ -151,3 +151,8 @@ impl fmt::Debug for Session {
self.state.fmt(f)
}
}

#[inline]
fn into_io_error<E: std::error::Error>(e: E) -> Error {
Error::new(ErrorKind::Other, e.to_string())
}

0 comments on commit 5aef7f8

Please # to comment.