aboutsummaryrefslogtreecommitdiff
path: root/src/util/data.rs
diff options
context:
space:
mode:
authorAlex Auvolat <alex@adnab.me>2023-01-03 15:29:29 +0100
committerAlex Auvolat <alex@adnab.me>2023-01-03 15:29:29 +0100
commita54b67740d08e3fabeb1652a1bed14d78fea4b74 (patch)
treedc672e5ff9ab83b95635f2ff30c17cd8c2bcedce /src/util/data.rs
parent8d5505514f950dc1ca1249a3385c9913b5b5e8e0 (diff)
downloadgarage-a54b67740d08e3fabeb1652a1bed14d78fea4b74.tar.gz
garage-a54b67740d08e3fabeb1652a1bed14d78fea4b74.zip
move debug_serialize to garage_util::encode
Diffstat (limited to 'src/util/data.rs')
-rw-r--r--src/util/data.rs16
1 files changed, 0 insertions, 16 deletions
diff --git a/src/util/data.rs b/src/util/data.rs
index b2a52e25..3f61e301 100644
--- a/src/util/data.rs
+++ b/src/util/data.rs
@@ -140,19 +140,3 @@ pub fn fasthash(data: &[u8]) -> FastHash {
pub fn gen_uuid() -> Uuid {
rand::thread_rng().gen::<[u8; 32]>().into()
}
-
-/// Serialize to JSON, truncating long result
-pub fn debug_serialize<T: Serialize>(x: T) -> String {
- match serde_json::to_string(&x) {
- Ok(ss) => {
- if ss.len() > 100 {
- // TODO this can panic if 100 is not a codepoint boundary, but inside a 2 Bytes
- // (or more) codepoint
- ss[..100].to_string()
- } else {
- ss
- }
- }
- Err(e) => format!("<JSON serialization error: {}>", e),
- }
-}