Append the specified value to this builder
(&mut self, v: &SqlInfoValue)
| 224 | |
| 225 | /// Append the specified value to this builder |
| 226 | pub fn append_value(&mut self, v: &SqlInfoValue) -> Result<()> { |
| 227 | // typeid is which child and len is the child array's length |
| 228 | // *after* adding the value |
| 229 | let (type_id, len) = match v { |
| 230 | SqlInfoValue::String(v) => { |
| 231 | self.string_values.append_value(v); |
| 232 | (0, self.string_values.len()) |
| 233 | } |
| 234 | SqlInfoValue::Bool(v) => { |
| 235 | self.bool_values.append_value(*v); |
| 236 | (1, self.bool_values.len()) |
| 237 | } |
| 238 | SqlInfoValue::BigInt(v) => { |
| 239 | self.bigint_values.append_value(*v); |
| 240 | (2, self.bigint_values.len()) |
| 241 | } |
| 242 | SqlInfoValue::Bitmask(v) => { |
| 243 | self.int32_bitmask_values.append_value(*v); |
| 244 | (3, self.int32_bitmask_values.len()) |
| 245 | } |
| 246 | SqlInfoValue::StringList(values) => { |
| 247 | // build list |
| 248 | for v in values { |
| 249 | self.string_list_values.values().append_value(v); |
| 250 | } |
| 251 | // complete the list |
| 252 | self.string_list_values.append(true); |
| 253 | (4, self.string_list_values.len()) |
| 254 | } |
| 255 | SqlInfoValue::ListMap(values) => { |
| 256 | // build map |
| 257 | for (k, v) in values.clone() { |
| 258 | self.int32_to_int32_list_map_values.keys().append_value(k); |
| 259 | self.int32_to_int32_list_map_values |
| 260 | .values() |
| 261 | .append_value(v.into_iter().map(Some)); |
| 262 | } |
| 263 | // complete the list |
| 264 | self.int32_to_int32_list_map_values.append(true)?; |
| 265 | (5, self.int32_to_int32_list_map_values.len()) |
| 266 | } |
| 267 | }; |
| 268 | |
| 269 | self.type_ids.append_value(type_id); |
| 270 | let len = i32::try_from(len).expect("offset fit in i32"); |
| 271 | self.offsets.append_value(len - 1); |
| 272 | Ok(()) |
| 273 | } |
| 274 | |
| 275 | /// Complete the construction and build the [`UnionArray`] |
| 276 | pub fn finish(self) -> UnionArray { |