1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
use async_trait::async_trait;

use crate::errors::my_errors::RetResult;
use crate::map::IndexType;

pub type MapType = std::sync::Arc<std::sync::RwLock<dyn Map>>;

#[async_trait]
pub trait Map: Send + Sync {
    fn new() -> MapType
    where
        Self: Sized;

    fn load(&mut self, points: Vec<Vec<i32>>) -> RetResult<()>;

    async fn load_from_file(&mut self, file_name: String) -> RetResult<()>;

    async fn load_from_string(&mut self, file_contend: String) -> RetResult<()>;

    fn find_path(
        &self,
        start: (IndexType, IndexType),
        end: (IndexType, IndexType),
    ) -> Vec<(IndexType, IndexType)>;

    fn set_walkable(
        &mut self,
        point: (IndexType, IndexType),
        walkable: i32,
    );

    fn in_map(&self, x: i32, y: i32) -> bool;
}