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

Method push

nodedb/src/control/arrow_convert.rs:124–148  ·  view source on GitHub ↗
(&mut self, value: &serde_json::Value)

Source from the content-addressed store, hash-verified

122 }
123
124 fn push(&mut self, value: &serde_json::Value) {
125 match self {
126 Self::Strings(v) => {
127 if let Some(s) = value.as_str() {
128 v.push(Some(s.to_string()));
129 } else if value.is_number() {
130 // Promote to numeric type.
131 let len = v.len();
132 if value.is_i64() {
133 let mut ints: Vec<Option<i64>> = v.iter().map(|_| None).collect();
134 ints.push(value.as_i64());
135 *self = Self::Ints(ints);
136 } else {
137 let mut floats: Vec<Option<f64>> = vec![None; len];
138 floats.push(value.as_f64());
139 *self = Self::Floats(floats);
140 }
141 } else {
142 v.push(Some(value.to_string()));
143 }
144 }
145 Self::Ints(v) => v.push(value.as_i64()),
146 Self::Floats(v) => v.push(value.as_f64()),
147 }
148 }
149
150 fn push_null(&mut self) {
151 match self {

Callers 2

push_nullMethod · 0.45

Calls 7

to_stringMethod · 0.80
collectMethod · 0.80
as_strMethod · 0.45
lenMethod · 0.45
iterMethod · 0.45
as_i64Method · 0.45
as_f64Method · 0.45

Tested by

no test coverage detected