Skip to main content

PushRequest

Struct PushRequest 

Source
pub struct PushRequest {
    pub project_key: String,
    pub file_path: String,
    pub content: Option<String>,
    pub source_env: String,
    pub deleted: bool,
    pub base_sha256: Option<String>,
}
Expand description

Body of POST /sync: one memory file, or one delete.

content is an Option, not a String, and that is load-bearing: it has to distinguish “this file is empty” (Some(""), serialized as "content":"") from “this is a delete, there is no content” (None, omitted entirely).

Skipping on emptiness instead — the obvious-looking skip_serializing_if = "String::is_empty" — omits the field for an empty file too, and the deployed Node server rejects that push with a 400, since typeof undefined !== "string". Both the Go and the first Rust implementation had exactly that bug, and neither test suite caught it: every test that exercised an empty file used a stand-in server that accepted anything. It surfaced only when the compatibility script ran a real empty-file push against the real Node server.

Fields§

§project_key: String

Which project this file belongs to. See recall_hooks::project.

§file_path: String

The file’s path relative to the project’s memory directory.

§content: Option<String>

The file’s exact bytes, or None to mean “this is a delete”.

§source_env: String

A label for the machine that sent this, for display only.

§deleted: bool

Whether this push is a delete rather than a write.

§base_sha256: Option<String>

content_sha256 of the version this edit started from: the content this client last pulled or pushed for the file. None when the client does not know — an older client, or a file it has never synced.

It is what lets the server tell the next edit from a concurrent one. Without it every push that differs from what is stored went through the semantic merge, which keeps “every distinct fact from both versions” — so a line deleted on purpose was a fact from the stored side and came back, and so did a resolved CONFLICT marker. When the stored version is the one named here, nothing happened in between and the push simply replaces it.

Implementations§

Source§

impl PushRequest

Source

pub fn validate(&self) -> Result<(), ValidationError>

Checks a push is well-formed, applying the same rules on both sides of the wire: the client refuses to send what the server would refuse to accept, so the user sees the real reason rather than a 400.

Trait Implementations§

Source§

impl Clone for PushRequest

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Debug for PushRequest

Source§

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

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

impl Default for PushRequest

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl<'de> Deserialize<'de> for PushRequest

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl PartialEq for PushRequest

Source§

fn eq(&self, other: &Self) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl Serialize for PushRequest

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl StructuralPartialEq for PushRequest

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> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

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> Same for T

Source§

type Output = T

Should always be Self
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 = !

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

fn try_from(value: U) -> Result<T, !>

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.