Enum FileRequest

Source
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.

Fields

§with_data: bool
§

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.

Fields

§path: String
§id: u64
§

CreateSnapshot

Fields

§root: String
§message: String
§

LoadSnapshotImage

Fields

§root: String
§hash: String
§

LoadSnapshot

Fields

§root: String
§hash: String
§

SaveSnapshotImage

Fields

§root: String
§hash: String
§data: Vec<u8>
§

SaveFile

Requests the collab server to apply the given delta to the given revision of the file with the given id.

Fields

§path: String
§data: String
§id: u64
§patch: bool
§

Search

Fields

§id: u64

Trait Implementations§

Source§

impl Clone for FileRequest

Source§

fn clone(&self) -> FileRequest

Returns a copy of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl DeBin for FileRequest

Source§

impl Debug for FileRequest

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more
Source§

impl SerBin for FileRequest

Source§

fn ser_bin(&self, s: &mut Vec<u8>)

Source§

fn serialize_bin(&self) -> Vec<u8>

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.