pub struct PushRequest {
pub project_key: String,
pub file_path: String,
pub content: Option<String>,
pub source_env: String,
pub deleted: bool,
}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: StringWhich project this file belongs to. See recall_hooks::project.
file_path: StringThe 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: StringA label for the machine that sent this, for display only.
deleted: boolWhether this push is a delete rather than a write.
Implementations§
Source§impl PushRequest
impl PushRequest
Sourcepub fn validate(&self) -> Result<(), ValidationError>
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
impl Clone for PushRequest
Source§fn clone(&self) -> PushRequest
fn clone(&self) -> PushRequest
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more