github.com/keybase/client/go@v0.0.0-20240309051027-028f7c731f8b/kbfs/kbfsedits/prepare.go (about) 1 // Copyright 2018 Keybase Inc. All rights reserved. 2 // Use of this source code is governed by a BSD 3 // license that can be found in the LICENSE file. 4 5 package kbfsedits 6 7 import "encoding/json" 8 9 // Prepare converts the given slice of notifications into a string 10 // suitable for sending/storing them. 11 func Prepare(edits []NotificationMessage) (string, error) { 12 buf, err := json.Marshal(edits) 13 if err != nil { 14 return "", err 15 } 16 return string(buf), nil 17 } 18 19 // PrepareSelfWrite converts the given message into a string suitable 20 // for sending/storing it. 21 func PrepareSelfWrite(msg SelfWriteMessage) (string, error) { 22 buf, err := json.Marshal(msg) 23 if err != nil { 24 return "", err 25 } 26 return string(buf), nil 27 }