aboutsummaryrefslogtreecommitdiff
path: root/src/data.rs
diff options
context:
space:
mode:
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)]