pub struct ReviewDocument {
pub schema_version: u32,
pub tool: String,
pub repo: String,
pub base: RefInfo,
pub head: RefInfo,
pub comments: Vec<Comment>,
}Expand description
The mutable review state for one (repo, base_sha, head_sha) diff.
Fields§
§schema_version: u32Schema generation this document was written with; readers reject
documents newer than they understand (SCHEMA_VERSION).
tool: StringProducing tool identifier ("packdiff"); distinguishes exported files
from look-alike JSON of other origins.
repo: StringRepository directory name the review belongs to.
base: RefInfoThe reviewed diff’s base ref, pinned to its SHA.
head: RefInfoThe reviewed diff’s head ref, pinned to its SHA.
comments: Vec<Comment>The comments, always in the canonical order (ReviewDocument::sort).
Implementations§
Source§impl ReviewDocument
impl ReviewDocument
pub fn new(repo: String, base: RefInfo, head: RefInfo) -> Self
Sourcepub fn parse(json: &str) -> Result<Self, ModelError>
pub fn parse(json: &str) -> Result<Self, ModelError>
Parse and validate a document. Rejects documents from a newer schema and any unknown field (strict deserialization); re-validates and re-sorts every comment so untrusted input (an imported file, a hand-edited store) is normalized on the way in.
Sourcepub fn to_json_pretty(&self) -> String
pub fn to_json_pretty(&self) -> String
Canonical serialized form (pretty, trailing newline) — what exports and the localStorage round-trip use.
Sourcepub fn upsert(&mut self, comment: Comment) -> Result<(), ModelError>
pub fn upsert(&mut self, comment: Comment) -> Result<(), ModelError>
Insert a new comment or replace the one with the same id.
Sourcepub fn delete(&mut self, id: &str) -> bool
pub fn delete(&mut self, id: &str) -> bool
Remove a comment by id. Returns whether anything was removed.
Sourcepub fn merge(&mut self, incoming: &ReviewDocument)
pub fn merge(&mut self, incoming: &ReviewDocument)
Merge another document’s comments into this one (the import path).
Semantics: union by id; on an id collision the comment with the
later updated_at wins (RFC 3339 UTC strings compare correctly
lexicographically); an exact tie keeps the existing comment. Metadata
(repo/refs) of self is kept — importing does not re-target a store.
Trait Implementations§
Source§impl Clone for ReviewDocument
impl Clone for ReviewDocument
Source§fn clone(&self) -> ReviewDocument
fn clone(&self) -> ReviewDocument
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for ReviewDocument
impl Debug for ReviewDocument
Source§impl<'de> Deserialize<'de> for ReviewDocument
impl<'de> Deserialize<'de> for ReviewDocument
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
impl Eq for ReviewDocument
Source§impl PartialEq for ReviewDocument
impl PartialEq for ReviewDocument
Source§fn eq(&self, other: &ReviewDocument) -> bool
fn eq(&self, other: &ReviewDocument) -> bool
self and other values to be equal, and is used by ==.