Encode a slice of `nodedb_types::Value` as a msgpack array. No JSON intermediary — values are serialized directly to standard msgpack.
(
values: &[nodedb_types::Value],
)
| 54 | /// |
| 55 | /// No JSON intermediary — values are serialized directly to standard msgpack. |
| 56 | pub(in crate::data::executor) fn encode_value_vec( |
| 57 | values: &[nodedb_types::Value], |
| 58 | ) -> crate::Result<Vec<u8>> { |
| 59 | let mut buf = Vec::with_capacity(values.len() * 64); |
| 60 | let n = values.len(); |
| 61 | if n <= 15 { |
| 62 | buf.push(0x90 | n as u8); |
| 63 | } else if n <= 0xFFFF { |
| 64 | buf.push(0xDC); |
| 65 | buf.extend_from_slice(&(n as u16).to_be_bytes()); |
| 66 | } else { |
| 67 | buf.push(0xDD); |
| 68 | buf.extend_from_slice(&(n as u32).to_be_bytes()); |
| 69 | } |
| 70 | for val in values { |
| 71 | let encoded = nodedb_types::value_to_msgpack(val).map_err(|e| crate::Error::Codec { |
| 72 | detail: format!("value serialization: {e}"), |
| 73 | })?; |
| 74 | buf.extend_from_slice(&encoded); |
| 75 | } |
| 76 | Ok(buf) |
| 77 | } |
| 78 | |
| 79 | /// Encode a simple `{"key": count}` response (for insert confirmations). |
| 80 | pub(in crate::data::executor) fn encode_count(key: &str, count: usize) -> crate::Result<Vec<u8>> { |
no test coverage detected