Parse a comma-separated list of `SocketAddr` strings. Returns `Ok(Vec )` if every entry parses successfully. Returns `Err(bad_entry)` with the first entry that fails to parse, so callers can log it and skip the entire override.
(s: &str)
| 401 | /// Returns `Err(bad_entry)` with the first entry that fails to parse, |
| 402 | /// so callers can log it and skip the entire override. |
| 403 | pub fn parse_seed_nodes(s: &str) -> crate::Result<Vec<SocketAddr>> { |
| 404 | let mut addrs = Vec::new(); |
| 405 | for entry in s.split(',') { |
| 406 | let entry = entry.trim(); |
| 407 | if entry.is_empty() { |
| 408 | continue; |
| 409 | } |
| 410 | match entry.parse::<SocketAddr>() { |
| 411 | Ok(addr) => addrs.push(addr), |
| 412 | Err(_) => { |
| 413 | return Err(crate::Error::Config { |
| 414 | detail: format!("invalid socket address: '{entry}'"), |
| 415 | }); |
| 416 | } |
| 417 | } |
| 418 | } |
| 419 | Ok(addrs) |
| 420 | } |
| 421 | |
| 422 | #[cfg(test)] |
| 423 | mod tests { |
no test coverage detected