MCPcopy Create free account
hub / github.com/NodeDB-Lab/nodedb / encode

Function encode

nodedb-cluster/src/swim/wire/codec.rs:18–22  ·  view source on GitHub ↗

Serialize a `SwimMessage` into a zerompk byte buffer.

(msg: &SwimMessage)

Source from the content-addressed store, hash-verified

16
17/// Serialize a `SwimMessage` into a zerompk byte buffer.
18pub fn encode(msg: &SwimMessage) -> Result<Vec<u8>, SwimError> {
19 zerompk::to_msgpack_vec(msg).map_err(|e| SwimError::Encode {
20 detail: e.to_string(),
21 })
22}
23
24/// Decode a zerompk byte buffer into a `SwimMessage`. Truncated or
25/// malformed input returns [`SwimError::Decode`] rather than panicking.

Callers 11

wrapFunction · 0.70
assert_roundtripFunction · 0.70
decode_rejects_truncatedFunction · 0.70
wire_tag_stability_pingFunction · 0.70
make_kv_put_requestFunction · 0.50
handle_streamFunction · 0.50
send_rpcMethod · 0.50
wrap_outboundMethod · 0.50

Calls 1

to_stringMethod · 0.80

Tested by 6

decode_rejects_truncatedFunction · 0.56
wire_tag_stability_pingFunction · 0.56
make_kv_put_requestFunction · 0.40