pub struct ViewOp {
pub format_version: u16,
pub kind: OpKind,
pub scope: Option<OpScope>,
pub provenance: Option<Provenance>,
pub depends: Vec<ContentHash>,
}Expand description
A typed operation carried in OpEntry::payload.
Fields§
§format_version: u16Wire-format version this op was written with; see FORMAT_VERSION.
kind: OpKindWhat the operation does to the view.
scope: Option<OpScope>The log and head this op was signed for, when the author bound it
to one. Additive (default + skip_serializing_if), so ops
written before scopes existed decode as None and re-serialize
byte-identically — invariant 1, and the reason adding a replay
defence is not a log migration.
provenance: Option<Provenance>How this op was authored, when not the default author-signed
class; see Provenance. Additive under the same rule as
scope, so every existing op decodes as None and re-serializes
byte-identically.
depends: Vec<ContentHash>Explicit change dependencies: content hashes of
the changes this op declares it builds on. Declared-only — the
platform never infers dependencies from file overlap; inference
is a separate decision. Additive under the same rule as scope
(an empty list is not serialized), and because it sits inside
the payload it is covered by the author’s (channel, payload)
signature (invariant 4) with no change to the signing scheme:
ops written before the field existed re-serialize
byte-identically, so their signatures still verify.
Implementations§
Source§impl ViewOp
impl ViewOp
Sourcepub fn new(kind: OpKind) -> Self
pub fn new(kind: OpKind) -> Self
Wraps kind at the current FORMAT_VERSION, unscoped, in the
default author-signed provenance class.
Sourcepub fn with_depends(self, depends: Vec<ContentHash>) -> Self
pub fn with_depends(self, depends: Vec<ContentHash>) -> Self
Declares the changes this op builds on. The list rides inside the signed payload, so a relay can neither strip nor extend it.
Sourcepub fn with_provenance(self, provenance: Provenance) -> Self
pub fn with_provenance(self, provenance: Provenance) -> Self
Labels this op with a non-default provenance class. Only the node’s push path does this; admission refuses the label under any other signer, so calling it from an ordinary author buys a rejection, not a classification.
Sourcepub fn in_scope(self, node: ContentHash, head: Option<ContentHash>) -> Self
pub fn in_scope(self, node: ContentHash, head: Option<ContentHash>) -> Self
Binds this op to one log and one observed head. The scope is inside the payload, so it is covered by the author’s signature and cannot be stripped or rewritten by whoever relays the bytes.
Sourcepub fn to_payload(&self) -> Vec<u8> ⓘ
pub fn to_payload(&self) -> Vec<u8> ⓘ
Serializes into an OpEntry::payload.