-
Notifications
You must be signed in to change notification settings - Fork 17
/
project_info.rs
40 lines (34 loc) · 1.08 KB
/
project_info.rs
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
38
39
40
// TODO(daemon): Remove ProjectInfo Request
//
// This is no longer relevant as the internal state get validated automatically
use super::*;
/// Return current working direcotry project info
#[derive(Debug, Serialize, Deserialize)]
pub struct ProjectInfo {
pub client: Client,
}
#[cfg(feature = "lua")]
impl<'a> Requester<'a, ProjectInfo> for ProjectInfo {}
#[cfg(feature = "daemon")]
#[async_trait]
impl Handler for ProjectInfo {
async fn handle(self, state: DaemonState) -> Result<()> {
let (root, _) = (&self.client.root, self.client.pid);
tracing::info!("Getting info for {}", root);
let mut state = state.lock().await;
state.get_mut_workspace(root)?.sync_state().await?;
Ok(())
}
}
#[cfg(feature = "lua")]
impl<'a> FromLua<'a> for ProjectInfo {
fn from_lua(v: LuaValue<'a>, _: &'a Lua) -> LuaResult<Self> {
if let LuaValue::Table(table) = v {
Ok(Self {
client: table.get("client")?,
})
} else {
Err(LuaError::external("Fail to deserialize ProjectInfo"))
}
}
}