docs/generated/contracts.mdgenerated from code
Reference · 4 min read
api-history
Contracts: api-history.
Read as
Source: crates/lvcs-api/src/history.rs.
1/// `blame` (discussion:owner/303): who wrote each line of the file at `address` on2/// `main`, at `heads` (change ids, `<peer:016x><counter:08x>`), or at the heads this3/// daemon last rendered when omitted, from the document's own history: an4/// author holds a line when a character it inserted is visible there.5#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]6pub struct BlameParams {7 pub address: String,8 #[serde(default, skip_serializing_if = "Option::is_none")]9 pub heads: Option<Vec<String>>,10}1112/// `blame` result: the heads blamed at, and each author with the line runs13/// it holds, sorted by name. A binary or deleted file names no lines.14#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]15pub struct BlameResult {16 pub heads: Vec<String>,17 #[serde(default)]18 pub authors: Vec<BlameAuthor>,19}2021/// One author of a file's lines.22#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]23pub struct BlameAuthor {24 /// Its peer id (`ID_ENCODING`); absent for a Loro peer25 /// whose signer this daemon hasn't verified.26 #[serde(default, skip_serializing_if = "Option::is_none")]27 pub peer: Option<String>,28 /// Its name (`Named`), or `unknown`.29 pub name: String,30 /// The line runs it holds, in order, without `near`.31 pub lines: Vec<LineName>,32}3334/// `change.signers` (discussion:owner/685): who signed each change id in `ids`35/// (`<peer:016x><counter:08x>`, as a frontier's or a document's heads name36/// them), at most `CHANGE_SIGNERS_MAX` of them. A change's signer never37/// changes, so an answer may be cached per id.38#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]39pub struct ChangeSignersParams {40 pub ids: Vec<String>,41}4243/// `change.signers` result: each asked id's signer, a peer id44/// (`ID_ENCODING`). An id whose signer this node hasn't verified is left45/// out.46#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]47pub struct ChangeSignersResult {48 #[serde(default)]49 pub signers: std::collections::BTreeMap<String, String>,50}5152/// `main.versions` (discussion:owner/687): main's newest saved versions the53/// daemon keeps (`MAIN_VERSIONS_KEPT`), newest first, at most `limit`54/// (default and most `MAIN_VERSIONS_MAX`), each before `before_ms` when55/// given, so a reader pages back by the oldest one it holds.56#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]57pub struct MainVersionsParams {58 #[serde(default, skip_serializing_if = "Option::is_none")]59 pub limit: Option<u32>,60 #[serde(default, skip_serializing_if = "Option::is_none")]61 pub before_ms: Option<i64>,62}6364/// One version of main: a save that moved main, one signer's saves in one65/// second taken as one. `frontier` is main's frontier right after it66/// (`ID_ENCODING`), `at_ms` its signed change's time, `signer` its peer id67/// when the daemon verified it, `paths` the files it changed (at most68/// `MAIN_VERSION_PATHS_MAX`), and `more` how many more.69#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]70pub struct MainVersion {71 pub frontier: String,72 pub at_ms: i64,73 #[serde(default, skip_serializing_if = "Option::is_none")]74 pub signer: Option<String>,75 #[serde(default)]76 pub paths: Vec<String>,77 #[serde(default, skip_serializing_if = "is_zero")]78 pub more: u32,79}8081/// `main.versions` result: the versions, newest first.82#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]83pub struct MainVersionsResult {84 #[serde(default)]85 pub versions: Vec<MainVersion>,86}8788const fn is_zero(n: &u32) -> bool {89 *n == 090}9192/// `channel.history` (discussion:owner/303): the moves of channel `channel`'s value93/// this daemon saw in its run, newest first, at most `limit` (every one94/// kept when omitted).95#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]96pub struct ChannelHistoryParams {97 pub channel: String,98 #[serde(default, skip_serializing_if = "Option::is_none")]99 pub limit: Option<u32>,100}101102/// `channel.history` result.103#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]104pub struct ChannelHistoryResult {105 #[serde(default)]106 pub moves: Vec<ChannelMove>,107}108109/// One move of a channel's value.110#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]111pub struct ChannelMove {112 /// The value it moved to: frontier ids (`ID_ENCODING`), sorted; empty113 /// for none.114 pub frontiers: Vec<String>,115 /// When, by this daemon's clock, in Unix milliseconds.116 pub at_ms: i64,117}118119/// `file.history` (discussion:owner/399 and discussion:owner/500): the saves of the file at120/// `address` on `main` up to `at` (the heads this daemon last rendered121/// when omitted) and after `since` (its saves at or before those heads122/// left out; every save when omitted), newest first, at most `limit`123/// (`FILE_HISTORY_MAX` when omitted or larger). A save is one change to124/// the file's text. Heads the file doesn't hold are `UNKNOWN_BASE`.125#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]126pub struct FileHistoryParams {127 pub address: String,128 #[serde(default, skip_serializing_if = "Option::is_none")]129 pub limit: Option<u32>,130 #[serde(default, skip_serializing_if = "Option::is_none")]131 pub since: Option<Vec<String>>,132 #[serde(default, skip_serializing_if = "Option::is_none")]133 pub at: Option<Vec<String>>,134}135136/// `file.history` result: the heads listed at, and the saves. A binary or137/// deleted file's saves name no lines.138#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]139pub struct FileHistoryResult {140 pub heads: Vec<String>,141 #[serde(default)]142 pub saves: Vec<FileSave>,143}144145/// One save of a file.146#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]147pub struct FileSave {148 /// The file as it was at this save is `read { heads }` with these149 /// (change ids, `<peer:016x><counter:08x>`).150 pub heads: Vec<String>,151 /// Its signed commit time, in Unix milliseconds (whole seconds).152 pub at_ms: i64,153 /// Its author's peer id (`ID_ENCODING`), as `BlameAuthor`'s.154 #[serde(default, skip_serializing_if = "Option::is_none")]155 pub peer: Option<String>,156 /// Its author's name (`Named`), or `unknown`.157 pub name: String,158 /// The lines of the file at this save it touched, in order, without159 /// `near`.160 #[serde(default)]161 pub lines: Vec<LineName>,162}163164/// The most saves one `file.history` lists.165pub const FILE_HISTORY_MAX: u32 = 200;