Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: make Add::get_json_stats public #2822

Merged
merged 1 commit into from
Aug 23, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading