Skip to main content

pingap_location/
lib.rs

1// Copyright 2024-2025 Tree xie.
2//
3// Licensed under the Apache License, Version 2.0 (the "License");
4// you may not use this file except in compliance with the License.
5// You may obtain a copy of the License at
6//
7// http://www.apache.org/licenses/LICENSE-2.0
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS,
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
14
15use std::collections::HashMap;
16use std::sync::Arc;
17
18/// Location provider trait
19pub trait LocationProvider: Send + Sync {
20    /// Get a location by name
21    ///
22    /// # Arguments
23    /// * `name` - The name of the location to get
24    ///
25    /// # Returns
26    /// * `Option<Arc<Location>>` - The location if found, None otherwise
27    fn get(&self, name: &str) -> Option<Arc<Location>>;
28    /// Get the stats of the locations
29    ///
30    /// # Returns
31    /// * `HashMap<String, LocationStats>` - The stats of the locations
32    fn stats(&self) -> HashMap<String, LocationStats>;
33}
34
35mod location;
36
37mod regex;
38
39pub use location::*;