Skip to content

Commit

Permalink
Make Add::get_json_stats public
Browse files Browse the repository at this point in the history
  • Loading branch information
gruuya authored and rtyler committed Aug 23, 2024
1 parent 53749f0 commit 46b38d2
Showing 1 changed file with 4 additions and 10 deletions.
14 changes: 4 additions & 10 deletions crates/core/src/protocol/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -259,17 +259,11 @@ impl Add {

/// Returns the serde_json representation of stats contained in the action if present.
/// Since stats are defined as optional in the protocol, this may be None.
fn get_json_stats(&self) -> Result<Option<Stats>, serde_json::error::Error> {
let ps: Result<Option<PartialStats>, serde_json::error::Error> = self
.stats
pub fn get_json_stats(&self) -> Result<Option<Stats>, serde_json::error::Error> {
self.stats
.as_ref()
.map_or(Ok(None), |s| serde_json::from_str(s));

match ps {
Ok(Some(mut partial)) => Ok(Some(partial.as_stats())),
Ok(None) => Ok(None),
Err(e) => Err(e),
}
.map(|stats| serde_json::from_str(stats).map(|mut ps: PartialStats| ps.as_stats()))
.transpose()
}
}

Expand Down

0 comments on commit 46b38d2

Please sign in to comment.