Skip to main content

AccountPage

Struct AccountPage 

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

One page of a replica’s account of what it holds in a space, signed by the replica and sealed with a space key.

In CBOR, a page is [1, header, body, signature], where the header is [space, epoch, author, page, issued] and the body an envelope (Envelope) sealed with the key derived from the space key of epoch, with the header’s encoding as associated data; the signature signs the encoding of [header, body].

Implementations§

Source§

impl AccountPage

Source

pub fn issue( space: SpaceId, keys: &SpaceKeys, signing: &SigningKey, (issued, body): (u64, &PageBody), rng: &mut impl CryptoRng, ) -> Self

Issues a page of the account of signing’s replica in space, telling body, sealed with the space key that new changes are wrapped with, and issued at issued, in milliseconds since 1970.

Source

pub fn issue_about( space: SpaceId, keys: &SpaceKeys, signing: &SigningKey, backup: EntityId, (issued, body): (u64, &PageBody), rng: &mut impl CryptoRng, ) -> Self

Issues a page of the account of a backup in space, which signing’s replica updated, as AccountPage::issue issues one of its own.

Source

pub fn from_bytes(bytes: &[u8]) -> Result<Self, LogError>

Reads a page from its encoding, and checks its signature: one that does not read, is longer than MAX_PAGE_LEN, or whose author did not sign it, is refused.

§Errors

Returns LogError::Account or LogError::Operations if the bytes are not a page, and LogError::InvalidSignature if its signature does not check.

Source

pub fn to_bytes(&self) -> Vec<u8> ⓘ

Its encoding, as it is stored and sent.

Source

pub fn id(&self) -> Hash

The BLAKE3 hash of its encoding, by which reconciliation knows it.

Source

pub fn open(&self, keys: &SpaceKeys) -> Result<PageBody, LogError>

Opens what the page tells, with the space key it was sealed with.

§Errors

Returns LogError::UnknownEpoch if keys lack that key, LogError::Decryption if the body does not open, and LogError::Account or LogError::Operations if what it holds does not read.

Source

pub const fn space(&self) -> SpaceId

The space whose account it is a page of.

Source

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

The verifying key of the replica that issued it.

Source

pub const fn kind(&self) -> PageKind

Which page it is.

Source

pub const fn about(&self) -> Option<EntityId>

The backup whose account it is a page of, if it is not its author’s own.

Source

pub const fn issued(&self) -> u64

When it was issued, in milliseconds since 1970.

Source

pub const fn epoch(&self) -> u64

The number of the space key that seals it.

Trait Implementations§

Source§

impl Clone for AccountPage

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 AccountPage

Source§

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

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

impl Eq for AccountPage

Source§

impl PartialEq for AccountPage

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 AccountPage

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> 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.