MCPcopy Create free account
hub / github.com/chirpstack/chirpstack / struct_to_binary

Function struct_to_binary

chirpstack/src/codec/mod.rs:94–109  ·  view source on GitHub ↗
(
    codec: Codec,
    f_port: u8,
    variables: &HashMap<String, String>,
    encoder_config: &str,
    obj: &prost_types::Struct,
)

Source from the content-addressed store, hash-verified

92}
93
94pub async fn struct_to_binary(
95 codec: Codec,
96 f_port: u8,
97 variables: &HashMap<String, String>,
98 encoder_config: &str,
99 obj: &prost_types::Struct,
100) -> Result<(u8, Vec<u8>)> {
101 Ok(match codec {
102 Codec::NONE => (f_port, Vec::new()),
103 Codec::CAYENNE_LPP => (
104 f_port,
105 cayenne_lpp::encode(obj).context("CayenneLpp encode")?,
106 ),
107 Codec::JS => js::encode(f_port, variables, encoder_config, obj).await?,
108 })
109}
110
111pub fn get_measurements(s: &pbjson_types::Struct) -> HashMap<String, pbjson_types::value::Kind> {
112 let mut out: HashMap<String, pbjson_types::value::Kind> = HashMap::new();

Callers 2

handle_down_commandFunction · 0.85
enqueueMethod · 0.85

Calls 1

encodeFunction · 0.50

Tested by

no test coverage detected