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

Function encode_response

nodedb/src/control/server/native/codec.rs:99–112  ·  view source on GitHub ↗

Encode a response in the given format.

(resp: &NativeResponse, format: FrameFormat)

Source from the content-addressed store, hash-verified

97
98/// Encode a response in the given format.
99pub fn encode_response(resp: &NativeResponse, format: FrameFormat) -> crate::Result<Vec<u8>> {
100 match format {
101 FrameFormat::Json => sonic_rs::to_vec(resp).map_err(|e| crate::Error::Serialization {
102 format: "json".into(),
103 detail: format!("response encode: {e}"),
104 }),
105 FrameFormat::MessagePack => {
106 zerompk::to_msgpack_vec(resp).map_err(|e| crate::Error::Serialization {
107 format: "msgpack".into(),
108 detail: format!("response encode: {e}"),
109 })
110 }
111 }
112}
113
114#[cfg(test)]
115mod tests {

Callers 4

response_encode_jsonFunction · 0.70
response_encode_msgpackFunction · 0.70
chunk_large_responseFunction · 0.70
runMethod · 0.70

Calls

no outgoing calls

Tested by 2

response_encode_jsonFunction · 0.56
response_encode_msgpackFunction · 0.56