Skip to main content

over_there/core/msg/content/request/
mod.rs

1mod batch;
2mod capabilities;
3mod custom;
4mod forward;
5mod internal_debug;
6mod io;
7mod sequence;
8mod transform;
9
10pub use batch::*;
11pub use capabilities::*;
12pub use custom::*;
13pub use forward::*;
14pub use internal_debug::*;
15pub use io::*;
16pub use sequence::*;
17pub use transform::*;
18
19use schemars::JsonSchema;
20use serde::{Deserialize, Serialize};
21
22// NOTE: Cannot adjacently tag as JsonSchema does not support it and
23//       it leads to deserialization errors with enum variants without
24//       any real arguments (empty struct doesn't fix)
25#[derive(JsonSchema, Serialize, Deserialize, Clone, Debug, PartialEq, Eq)]
26// #[serde(tag = "type")]
27#[serde(tag = "type", content = "payload")]
28pub enum Request {
29    // ------------------------------------------------------------------------
30    // Heartbeats are used to ensure remote instances are alive
31    #[serde(rename = "heartbeat_request")]
32    #[allow(dead_code)]
33    Heartbeat,
34
35    // ------------------------------------------------------------------------
36    // Version information to ensure that we don't have
37    // conflicting functionality
38    #[serde(rename = "version_request")]
39    #[allow(dead_code)]
40    Version,
41
42    // ------------------------------------------------------------------------
43    // Capability information to convey what is available remotely, which
44    // can differ based on enabled features at compile time
45    #[serde(rename = "capabilities_request")]
46    #[allow(dead_code)]
47    Capabilities,
48
49    // ------------------------------------------------------------------------
50    // Dir-based operations such as creating and listing entries
51    /// This will be sent to indicate the desire to create a new directory
52    #[serde(rename = "create_dir_request")]
53    CreateDir(CreateDirArgs),
54
55    /// This will be sent to indicate the desire to rename a directory
56    #[serde(rename = "rename_dir_request")]
57    RenameDir(RenameDirArgs),
58
59    /// This will be sent to indicate the desire to remove a directory
60    #[serde(rename = "remove_dir_request")]
61    RemoveDir(RemoveDirArgs),
62
63    /// This will be sent to indicate the desire to list all files/directories
64    /// at the provided path
65    #[serde(rename = "list_dir_contents_request")]
66    ListDirContents(ListDirContentsArgs),
67
68    // ------------------------------------------------------------------------
69    // File-based operations such as reading and writing
70    /// This will be sent to indicate the desire to read/write a file,
71    /// and can also be used to retrieve an already-open file's id/sig
72    #[serde(rename = "open_file_request")]
73    OpenFile(OpenFileArgs),
74
75    /// This will be sent to indicate the desire to close an open file
76    #[serde(rename = "close_file_request")]
77    CloseFile(CloseFileArgs),
78
79    /// This will be sent to indicate the desire to rename a file
80    #[serde(rename = "rename_unopened_file_request")]
81    RenameUnopenedFile(RenameUnopenedFileArgs),
82
83    /// This will be sent to indicate the desire to rename an open file
84    #[serde(rename = "rename_file_request")]
85    RenameFile(RenameFileArgs),
86
87    /// This will be sent to indicate the desire to remove a file
88    #[serde(rename = "remove_unopened_file_request")]
89    RemoveUnopenedFile(RemoveUnopenedFileArgs),
90
91    /// This will be sent to indicate the desire to remove an open file
92    #[serde(rename = "remove_file_request")]
93    RemoveFile(RemoveFileArgs),
94
95    /// This will be sent to indicate the desire to read a file's contents
96    #[serde(rename = "read_file_request")]
97    ReadFile(ReadFileArgs),
98
99    /// This will be sent to indicate the desire to write a file's contents
100    #[serde(rename = "write_file_request")]
101    WriteFile(WriteFileArgs),
102
103    // ------------------------------------------------------------------------
104    // Program execution operations such as running and streaming
105    /// This will be sent to execute a remote proccess on the server
106    #[serde(rename = "exec_proc_request")]
107    ExecProc(ExecProcArgs),
108
109    /// This will be sent to feed input to a remote process on the server, if
110    /// enabled when first executing
111    #[serde(rename = "write_proc_stdin_request")]
112    WriteProcStdin(WriteProcStdinArgs),
113
114    /// This will be sent to request all stdout for a remote process on
115    /// the server since the last request was made
116    #[serde(rename = "read_proc_stdout_request")]
117    ReadProcStdout(ReadProcStdoutArgs),
118
119    /// This will be sent to request all stderr for a remote process on
120    /// the server since the last request was made
121    #[serde(rename = "read_proc_stderr_request")]
122    ReadProcStderr(ReadProcStderrArgs),
123
124    /// This will be sent to kill a remote process on the server
125    #[serde(rename = "kill_proc_request")]
126    KillProc(KillProcArgs),
127
128    /// This will be sent to request the status of a running process on
129    /// the server
130    #[serde(rename = "read_proc_status_request")]
131    ReadProcStatus(ReadProcStatusArgs),
132
133    // ------------------------------------------------------------------------
134    // Miscellaneous, adhoc messages
135    /// This will be sent to execute a collection of operations sequentially
136    #[serde(rename = "sequence_request")]
137    Sequence(SequenceArgs),
138
139    /// This will be sent to execute a collection of operations in parallel
140    #[serde(rename = "batch_request")]
141    Batch(BatchArgs),
142
143    /// This will be sent to either the client or server and the msg will be
144    /// passed along to the associated address (if possible)
145    #[serde(rename = "forward_request")]
146    Forward(ForwardArgs),
147
148    /// This will be sent in either direction to provide a custom content
149    /// that would be evaluated through user-implemented handlers
150    #[serde(rename = "custom_request")]
151    Custom(CustomArgs),
152
153    /// For debugging purposes when needing to query the state of client/server
154    #[serde(rename = "internal_debug_request")]
155    InternalDebug(InternalDebugArgs),
156}
157
158impl Request {
159    /// Converts a request into a lazily transformed request using the
160    /// provided rules as transformation specifications
161    pub fn into_lazily_transformed(
162        self,
163        rules: Vec<TransformRule>,
164    ) -> LazilyTransformedRequest {
165        LazilyTransformedRequest::new(self, rules)
166    }
167}
168
169impl crate::core::SchemaInfo for Request {}