docs/generated/contracts.mdgenerated from code
Reference · 2 min read
api-writes
Contracts: api-writes.
Read as
Source: crates/lvcs-api/src/writes.rs.
1/// What a write says its writer will do to the range (discussion:owner/513), a JSON2/// string: `adding`, `changing`, or `removing`.3#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]4#[serde(rename_all = "snake_case")]5pub enum WriteOp {6 Adding,7 Changing,8 Removing,9}1011/// A `write` event's `data`. Without `done`, the writer's tool is about to12/// write the path: the next change the daemon reconciles there while the13/// write stands is the writer's, against its `base` (without14/// one, the heads the tree's index shows for the path now; none for a new15/// file), and the range of `old`'s first occurrence (the whole file when16/// `old` is absent or can't be found) is announced with `op` (default17/// `changing`) and `what`. It lapses at the writer's `done` event, or18/// `INTENT_TTL_MS` after it with no change; the same writer again replaces19/// it, and two writers' writes on one path both drop, so the change is20/// the host participant's. With `done`, the tool has written the path, or21/// failed. Errors: `UNKNOWN_BASE`, `REJECTED` (no message grant on the22/// path). With no gossip token the write stands unannounced, and its23/// save's automatic announcement tells the others (discussion:owner/444).24/// With `quiet`, only the tree hears the intent and nothing is announced:25/// a harness's guess that a command it runs may write the path26/// (discussion:owner/624), which the save announces if it does.27#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]28#[serde(default)]29pub struct WriteBody {30 /// The heads the writer read at the event's address.31 #[serde(skip_serializing_if = "Vec::is_empty")]32 pub base: Vec<String>,33 /// The line ranges the write touches, when it says.34 #[serde(skip_serializing_if = "Vec::is_empty")]35 pub ranges: Vec<crate::events::EventRange>,36 #[serde(skip_serializing_if = "Option::is_none")]37 pub op: Option<WriteOp>,38 #[serde(skip_serializing_if = "String::is_empty")]39 pub what: String,40 #[serde(skip_serializing_if = "Option::is_none")]41 pub old: Option<String>,42 #[serde(skip_serializing_if = "std::ops::Not::not")]43 pub done: bool,44 #[serde(skip_serializing_if = "std::ops::Not::not")]45 pub quiet: bool,46 /// The hex SHA-256 of the exact bytes the writer's tool starts from,47 /// as its hook read them right before the tool ran48 /// (discussion:owner/777): proof of the read when a version holds them.49 #[serde(skip_serializing_if = "Option::is_none")]50 pub read_hash: Option<String>,51}