tp_lib_core/detections/
load.rs1use std::path::Path;
6
7use crate::io::csv::detections as csv_loader;
8use crate::io::geojson::detections as geojson_loader;
9use crate::models::{Detection, DetectionKind};
10
11use super::error::DetectionError;
12
13pub fn load_detections(
21 path: &Path,
22 expected_kind: DetectionKind,
23) -> Result<Vec<Detection>, DetectionError> {
24 let ext = path
25 .extension()
26 .and_then(|s| s.to_str())
27 .map(|s| s.to_ascii_lowercase())
28 .unwrap_or_default();
29
30 match ext.as_str() {
31 "csv" => csv_loader::load(path, expected_kind),
32 "geojson" | "json" => geojson_loader::load(path, expected_kind),
33 _ => Err(DetectionError::UnsupportedExtension(ext)),
34 }
35}