clankerdiff_protocol/client/
message.rs1use crate::shared::{ProtocolError, decode_json, encode_json};
2use clankerdiff_core::{DiffScope, RepositoryAction, ReviewSubmission};
3use serde::{Deserialize, Serialize};
4
5#[derive(Debug, Clone, Serialize, Deserialize)]
6pub enum ClientCommand {
7 Initialize {
8 protocol_version: u32,
9 scope: DiffScope,
10 },
11 SetScope(DiffScope),
12 Apply(RepositoryAction),
13 Refresh,
14 Submit(ReviewSubmission),
15 Cancel,
16}
17
18impl ClientCommand {
19 pub fn encode(&self) -> Result<String, ProtocolError> {
20 encode_json(self)
21 }
22
23 pub fn decode(text: &str) -> Result<Self, ProtocolError> {
24 decode_json(text)
25 }
26}