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

Function decode

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

Decode a zerompk byte buffer into a `SwimMessage`. Truncated or malformed input returns [`SwimError::Decode`] rather than panicking.

(bytes: &[u8])

Source from the content-addressed store, hash-verified

24/// Decode a zerompk byte buffer into a `SwimMessage`. Truncated or
25/// malformed input returns [`SwimError::Decode`] rather than panicking.
26pub fn decode(bytes: &[u8]) -> Result<SwimMessage, SwimError> {
27 zerompk::from_msgpack(bytes).map_err(|e| SwimError::Decode {
28 detail: e.to_string(),
29 })
30}
31
32#[cfg(test)]
33mod tests {

Callers 6

unwrapFunction · 0.70
assert_roundtripFunction · 0.70
handshake_on_duplexFunction · 0.50
handle_streamFunction · 0.50
parse_inboundMethod · 0.50

Calls 1

to_stringMethod · 0.80

Tested by

no test coverage detected