Skip to main content

Change

Struct Change 

Source
pub struct Change { /* private fields */ }
Expand description

The operations that one replica made at one time, signed by the replica. The payload that holds them is sealed with a key of the change’s own, and kept beside the change, whose header holds the hashes of both.

In CBOR, a change is the array [1, header, signature]. docs/spec/log.md describes the format.

Implementations§

Source§

impl Change

Source

pub fn create( space: SpaceId, keys: &SpaceKeys, author: &SigningKey, draft: &Draft, rng: &mut impl CryptoRng, ) -> Parcel

Makes a change: seals the draft’s payload with a new change key, wraps that key with the space’s newest key, and signs the change as author.

Source

pub const fn id(&self) -> ChangeId

The change’s ID.

Source

pub const fn space(&self) -> SpaceId

The space the change belongs to.

Source

pub const fn epoch(&self) -> u64

The number of the space key that wraps the change’s key.

Source

pub const fn author(&self) -> &VerifyingKey

The replica that made the change.

Source

pub const fn parents(&self) -> &SmallSet<ChangeId>

The changes that the author’s log ended with when the author made this one.

Source

pub const fn timestamp(&self) -> Timestamp

The change’s system time.

Source

pub const fn kind(&self) -> Kind

What the change is for.

Source

pub const fn payload_hash(&self) -> &Hash

The hash of the change’s sealed payload.

Source

pub const fn sealed(&self) -> &BTreeMap<StatementId, Hash>

The secret statements sealed in the change’s payload, with the hashes of their record keys, by ID.

Source

pub const fn purges(&self) -> &Purges

What the change purges.

Source

pub const fn restores(&self) -> &Restores

What the change restores, of what purges destroyed.

Source

pub fn purges_or_restores(&self) -> bool

Whether the change purges or restores anything, which the same roles may do.

Source

pub fn verify(&self) -> Result<(), LogError>

Checks the change’s signature.

§Errors

Returns LogError::InvalidSignature if the signature is not valid for the author.

Source

pub fn open( &self, payload: &SealedPayload, key: &WrappedChangeKey, keys: &SpaceKeys, ) -> Result<Payload, LogError>

Decrypts the change’s payload with the change’s key, which key holds wrapped. Sealed statements stay sealed.

§Errors

Returns an error if the payload is not this change’s, if keys lack the space key of the change’s epoch, if the wrapped key is not this change’s, or if the payload does not have the form of a payload, or seals other statements than the header says.

Trait Implementations§

Source§

impl Clone for Change

Source§

fn clone(&self) -> Self

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 Change

Source§

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

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

impl Eq for Change

Source§

impl FromCbor for Change

Source§

fn from_cbor(value: &Cbor) -> Result<Self, Error>

Reads the Rust value from a decoded value. Read more
Source§

impl Header for Change

Source§

fn id(&self) -> ChangeId

The change’s ID.
Source§

fn author(&self) -> &VerifyingKey

The key that signed it.
Source§

fn timestamp(&self) -> Timestamp

When it was made, by its author’s clock.
Source§

fn is_root(&self) -> bool

Whether it is the space’s first change, with no parents.
Source§

fn space(&self) -> SpaceId

The space it is a change of.
Source§

fn purges_or_seals(&self) -> bool

Whether it purges or seals anything, or does anything else that destroys or hides content.
Source§

impl PartialEq for Change

Source§

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

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

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

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for Change

Source§

impl ToCbor for Change

Source§

fn to_cbor(&self) -> Cbor

Returns the value to encode.

Auto Trait Implementations§

§

impl Forget for Change

§

impl Freeze for Change

§

impl Move for Change

§

impl RefUnwindSafe for Change

§

impl Send for Change

§

impl Sync for Change

§

impl Unpin for Change

§

impl UnsafeUnpin for Change

§

impl UnwindSafe for Change

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> ErasedDestructor for T
where T: 'static,

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> Same for T

Source§

type Output = T

Should always be Self
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 = !

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

fn try_from(value: U) -> Result<T, !>

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.