pub enum FileRequest {
LoadFileTree {
with_data: bool,
},
OpenFile {
path: String,
id: u64,
},
CreateSnapshot {
root: String,
message: String,
},
LoadSnapshotImage {
root: String,
hash: String,
},
LoadSnapshot {
root: String,
hash: String,
},
SaveSnapshotImage {
root: String,
hash: String,
data: Vec<u8>,
},
SaveFile {
path: String,
data: String,
id: u64,
patch: bool,
},
Search {
id: u64,
set: Vec<SearchItem>,
},
}
Expand description
Types for the collab protocol.
The collab protocol is relatively simple. The collab server can open and close files. Each open file has a corresponding collaboration session, to/from which clients can add/remove themselves as participant. When a client requests to open a file, it really requests to be added as a participant to (the collaboration session of) that file. Similarly, when a client requests to close a file, it really requests to be removed as a participant from (the collaboration session) of that file. Files are only opened/closed as necessary, that is, when the first client is added or the last client removed as a participant.
Once the client is a participant for a file, it can request to apply deltas to that file. Deltas are always applied to a given revision of a file. Because of network latency, different clients clients may have different revisions of the same file. The server maintains a linear history of all deltas from the oldest revision to the newest revision. Whenever a delta for an older revision comes in, it is transformed against these older revisions so it can be applied to the newest revision. Only when all clients have confirmed that they have seen a revision (by sending a delta based on that revision) will the server remove that delta from its history.
Whenever a server applies a delta to a file, it notifies all the participants of that file except the one from which the request to apply the delta originated of this fact. This allows the participants to update their revision of the file accordingly. A type for representing a request to the collab server.
Variants§
LoadFileTree
Requests the collab server to return its file tree.
OpenFile
Requests the collab server to add the client as a participant to the file with the given id. If the client is the first participant for the file, this also causes the file to be opened on the server.
CreateSnapshot
LoadSnapshotImage
LoadSnapshot
SaveSnapshotImage
SaveFile
Requests the collab server to apply the given delta to the given revision of the file with the given id.
Search
Trait Implementations§
Source§impl Clone for FileRequest
impl Clone for FileRequest
Source§fn clone(&self) -> FileRequest
fn clone(&self) -> FileRequest
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read more