1use bincode::{Decode, Encode};
2use std::{fmt::Debug, path::PathBuf};
3
4#[derive(Debug, Decode, Encode, PartialEq, Eq, PartialOrd, Ord, Clone)]
5pub struct VersionHeader(pub String);
6
7#[derive(Debug, Decode, Encode, PartialEq, Eq, PartialOrd, Ord, Clone)]
8pub struct VersionResponse(pub VersionStatus);
9
10#[derive(Debug, Decode, Encode, PartialEq, Eq, PartialOrd, Ord, Clone)]
11pub enum VersionStatus {
12 Match,
13 Mismatch(String),
14}
15
16#[derive(Decode, Encode, PartialEq, Eq, PartialOrd, Ord, Clone)]
17pub struct Request {
18 pub action: Action,
19 pub path: PathBuf,
20 pub size: u64,
21 pub hash: u64,
22 pub password: [u8; 32],
23}
24
25impl Debug for Request {
26 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
27 f.debug_struct("Request")
28 .field("action", &self.action)
29 .field("path", &self.path)
30 .field("size", &self.size)
31 .field("hash", &self.hash)
32 .field("password", &"REDACTED")
33 .finish()
34 }
35}
36
37#[derive(Debug, Decode, Encode, PartialEq, Eq, PartialOrd, Ord, Clone, Copy)]
38pub enum Action {
39 Upload,
40 Run,
41}
42
43#[derive(Debug, Decode, Encode, PartialEq, Eq, PartialOrd, Ord, Clone)]
44pub struct Verification {
45 pub password: MatchStatus,
46 pub hash: MatchStatus,
47}
48
49impl Default for Verification {
50 fn default() -> Self {
51 Self {
52 password: MatchStatus::Mismatch,
53 hash: MatchStatus::Mismatch,
54 }
55 }
56}
57
58#[derive(Debug, Decode, Encode, PartialEq, Eq, PartialOrd, Ord, Clone, Copy)]
59pub enum MatchStatus {
60 Match,
61 Mismatch,
62}