MCPcopy Index your code
hub / github.com/foxcpp/maddy / parseUpdate

Function parseUpdate

internal/updatepipe/serialize.go:39–58  ·  view source on GitHub ↗
(s string)

Source from the content-addressed store, hash-verified

37}
38
39func parseUpdate(s string) (id string, upd *mess.Update, err error) {
40 parts := strings.SplitN(s, ";", 2)
41 if len(parts) != 2 {
42 return "", nil, errors.New("updatepipe: mismatched parts count")
43 }
44
45 upd = &mess.Update{}
46 dec := json.NewDecoder(strings.NewReader(unescapeName(parts[1])))
47 dec.UseNumber()
48 err = dec.Decode(upd)
49 if err != nil {
50 return "", nil, fmt.Errorf("parseUpdate: %w", err)
51 }
52
53 if val, ok := upd.Key.(json.Number); ok {
54 upd.Key, _ = strconv.ParseUint(val.String(), 10, 64)
55 }
56
57 return parts[0], upd, nil
58}
59
60func formatUpdate(myID string, upd mess.Update) (string, error) {
61 updBlob, err := json.Marshal(upd)

Callers 2

ListenMethod · 0.85
readUpdatesMethod · 0.85

Calls 2

unescapeNameFunction · 0.85
StringMethod · 0.45

Tested by

no test coverage detected