aboutsummaryrefslogtreecommitdiff
path: root/src/data.rs
diff options
context:
space:
mode:
authorAlex Auvolat <alex@adnab.me>2020-04-16 19:28:02 +0200
committerAlex Auvolat <alex@adnab.me>2020-04-16 19:28:02 +0200
commit2f3b1a072f63330c101d4e2703a24e0f26b98674 (patch)
treebfd11768154f81d8904a932f17f2cf5fe36038b1 /src/data.rs
parent2832be4396d2ed40bfb0bd4358bc14ef7432decb (diff)
downloadgarage-2f3b1a072f63330c101d4e2703a24e0f26b98674.tar.gz
garage-2f3b1a072f63330c101d4e2703a24e0f26b98674.zip
WIP
Diffstat (limited to 'src/data.rs')
-rw-r--r--src/data.rs13
1 files changed, 13 insertions, 0 deletions
diff --git a/src/data.rs b/src/data.rs
index fd7f9a8b..c1665d2a 100644
--- a/src/data.rs
+++ b/src/data.rs
@@ -111,6 +111,19 @@ where
Ok(wr)
}
+pub fn debug_serialize<T: Serialize>(x: T) -> String {
+ match serde_json::to_string(&x) {
+ Ok(ss) => {
+ if ss.len() > 100 {
+ ss[..100].to_string()
+ } else {
+ ss
+ }
+ }
+ Err(e) => format!("<JSON serialization error: {}>", e),
+ }
+}
+
// Network management
#[derive(Clone, Debug, Serialize, Deserialize)]