✨ client server api
This commit is contained in:
parent
164c71ddfe
commit
6e31b95417
6 changed files with 89 additions and 7 deletions
40
src/api.rs
40
src/api.rs
|
@ -105,3 +105,43 @@ impl Result {
|
|||
Self { ok: 0 }
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Serialize, Deserialize)]
|
||||
pub struct ClientAction {
|
||||
pub id: ulid::Ulid,
|
||||
pub action: ClientActions,
|
||||
}
|
||||
|
||||
impl ClientAction {
|
||||
pub fn new(action: ClientActions) -> Self {
|
||||
Self {
|
||||
id: ulid::Ulid::new(),
|
||||
action,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Serialize, Deserialize)]
|
||||
pub enum ClientActions {
|
||||
OSQuery(String),
|
||||
}
|
||||
|
||||
#[derive(Debug, Serialize, Deserialize)]
|
||||
pub struct ServerResponse {
|
||||
pub id: ulid::Ulid,
|
||||
pub response: ServerResponses,
|
||||
}
|
||||
|
||||
impl ServerResponse {
|
||||
pub fn of(client: &ClientAction, resp: ServerResponses) -> Self {
|
||||
Self {
|
||||
id: client.id,
|
||||
response: resp,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Serialize, Deserialize)]
|
||||
pub enum ServerResponses {
|
||||
OSQuery(String),
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue