1use async_trait::async_trait;
2
3use crate::errors::my_errors::RetResult;
4use crate::map::IndexType;
5
6pub type MapType = std::sync::Arc<tokio::sync::RwLock<dyn Map>>;
7
8#[async_trait]
9pub trait Map: Send + Sync {
10 fn new() -> MapType
11 where
12 Self: Sized;
13
14 fn load(&mut self, points: Vec<Vec<i32>>) -> RetResult<()>;
15
16 async fn load_from_file(&mut self, file_name: String) -> RetResult<()>;
17
18 async fn load_from_string(&mut self, file_contend: String) -> RetResult<()>;
19
20 fn find_path(
21 &self,
22 start: (IndexType, IndexType),
23 end: (IndexType, IndexType),
24 ) -> Vec<(IndexType, IndexType)>;
25
26 fn set_walkable(
27 &mut self,
28 point: (IndexType, IndexType),
29 walkable: i32,
30 );
31
32 fn in_map(&self, x: i32, y: i32) -> bool;
33}