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
34
35
36
37
use crate::io::provider::{EntryId, Path};

pub struct Location {
    element: &'static str,
}

impl Location {
    pub const fn new(element: &'static str) -> Self {
        Self { element }
    }

    pub fn of(&self, mut path: Path) -> Path {
        let entry_id: EntryId = EntryId::from(self.element);
        path.push(entry_id);
        path
    }

    pub fn of_server(&self) -> Path {
        self.of(server())
    }

    pub fn of_client(&self) -> Path {
        self.of(client())
    }

    pub fn root(&self) -> Path {
        Path::single(self.element)
    }
}

pub fn server() -> Path {
    Path::single("@server")
}

pub fn client() -> Path {
    Path::single("@self")
}