Skip to main content

ViewOp

Struct ViewOp 

Source
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: u16

Wire-format version this op was written with; see FORMAT_VERSION.

§kind: OpKind

What 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

Source

pub fn new(kind: OpKind) -> Self

Wraps kind at the current FORMAT_VERSION, unscoped, in the default author-signed provenance class.

Source

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.

Source

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.

Source

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.

Source

pub fn to_payload(&self) -> Vec<u8>

Serializes into an OpEntry::payload.

Source

pub fn from_payload(payload: &[u8]) -> Result<Self, ViewError>

Decodes an OpEntry::payload.

§Errors

Returns ViewError::Decode when the bytes are not a valid op.

Trait Implementations§

Source§

impl Clone for ViewOp

Source§

fn clone(&self) -> ViewOp

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for ViewOp

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<'de> Deserialize<'de> for ViewOp

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl PartialEq for ViewOp

Source§

fn eq(&self, other: &ViewOp) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Serialize for ViewOp

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl Eq for ViewOp

Source§

impl StructuralPartialEq for ViewOp

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,