Skip to main content

ReputationAttestation

Struct ReputationAttestation 

Source
pub struct ReputationAttestation {
    pub id: EventId,
    pub issuer: PublicKey,
    pub destination: PublicKey,
    pub subject: String,
    pub reviews: u32,
    pub rating_hundredths: u16,
    pub since: u64,
    pub created_at: u64,
    pub expiration: u64,
}
Expand description

A parsed, verified reputation attestation.

Fields§

§id: EventId

Event id, which identifies the attestation.

§issuer: PublicKey

Key the issuer signed with.

§destination: PublicKey

Identity the attestation is addressed to (p).

§subject: String

The source account, opaque and stable within the issuer.

§reviews: u32

Ratings received on the source.

§rating_hundredths: u16

Average of those ratings, in hundredths (487 is 4.87).

§since: u64

First completed trade on the source, a UTC day start.

§created_at: u64

When the issuer signed it.

§expiration: u64

When it stops being redeemable.

Implementations§

Source§

impl ReputationAttestation

Source

pub fn rating(&self) -> f64

Average rating as a number, 4.87 for rating_hundredths == 487.

The division is correctly rounded, so this is the same double as parsing the decimal string the event carries.

Source

pub fn rating_text(&self) -> String

Average rating as the event writes it, with two decimals.

Source

pub fn build( issuer: &Keys, destination: &PublicKey, subject: &str, reviews: u32, average: f64, since: u64, created_at: Timestamp, lifetime: u64, ) -> Result<Event, AttestationError>

Sign an attestation with the issuer’s dedicated key.

average is the issuer’s internal average; it is rounded and clamped as rating_hundredths does. The arguments are checked against the rules a destination applies, so a successful build always parses. lifetime is at most ATTESTATION_LIFETIME_SECS, the default cap.

Source

pub fn parse( event: &Event, now: Timestamp, max_lifetime: u64, ) -> Result<Self, AttestationError>

Parse and verify an attestation event.

Applies every rule of the event: id and signature, kind, z, each tag exactly once and in range, created_at no later than now plus the skew, expiration no earlier than now minus the skew, and a lifetime of at most max_lifetime seconds. The trust list, the receiver’s own issuer key and the identity match are the caller’s.

Source

pub fn parse_json( json: &str, now: Timestamp, max_lifetime: u64, ) -> Result<(Self, Event), AttestationError>

ReputationAttestation::parse on the JSON serialisation an attestation travels in. Returns the event too, so a caller can keep exactly what it received.

Trait Implementations§

Source§

impl Clone for ReputationAttestation

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 ReputationAttestation

Source§

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

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

impl Eq for ReputationAttestation

Source§

impl From<&ReputationAttestation> for ReputationImport

Source§

fn from(a: &ReputationAttestation) -> Self

Converts to this type from the input type.
Source§

impl PartialEq for ReputationAttestation

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 ReputationAttestation

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<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

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

Source§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

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

impl<S, T> Upcast<T> for S
where T: UpcastFrom<S> + ?Sized, S: ?Sized,

Source§

fn upcast(&self) -> &T
where Self: ErasableGeneric, T: Sized + ErasableGeneric<Repr = Self::Repr>,

Perform a zero-cost type-safe upcast to a wider ref type within the Wasm bindgen generics type system. Read more
Source§

fn upcast_into(self) -> T
where Self: Sized + ErasableGeneric, T: Sized + ErasableGeneric<Repr = Self::Repr>,

Perform a zero-cost type-safe upcast to a wider type within the Wasm bindgen generics type system. Read more
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more