MCPcopy Create free account
hub / github.com/cargo-lambda/cargo-lambda / visit_seq

Method visit_seq

crates/cargo-lambda-metadata/src/cargo/watch.rs:369–397  ·  view source on GitHub ↗
(self, seq: A)

Source from the content-addressed store, hash-verified

367 }
368
369 fn visit_seq<A>(self, seq: A) -> Result<Self::Value, A::Error>
370 where
371 A: serde::de::SeqAccess<'de>,
372 {
373 let routes: Vec<Route> =
374 Deserialize::deserialize(serde::de::value::SeqAccessDeserializer::new(seq))?;
375
376 let mut inner = Router::new();
377 let mut raw = Vec::new();
378
379 let mut routes_by_path = HashMap::new();
380
381 for route in &routes {
382 routes_by_path
383 .entry(route.path.clone())
384 .and_modify(|routes| merge_routes(routes, route))
385 .or_insert_with(|| decode_route(route));
386
387 raw.push(route.clone());
388 }
389
390 for (path, route) in &routes_by_path {
391 inner.insert(path, route.clone()).map_err(|e| {
392 serde::de::Error::custom(format!("Failed to insert route {path}: {e}"))
393 })?;
394 }
395
396 Ok(FunctionRouter { inner, raw })
397 }
398}
399
400fn merge_routes(routes: &mut FunctionRoutes, route: &Route) {

Callers

nothing calls this directly

Calls 5

newFunction · 0.85
merge_routesFunction · 0.85
decode_routeFunction · 0.85
pushMethod · 0.80
insertMethod · 0.80

Tested by

no test coverage detected