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: EventIdEvent id, which identifies the attestation.
issuer: PublicKeyKey the issuer signed with.
destination: PublicKeyIdentity the attestation is addressed to (p).
subject: StringThe source account, opaque and stable within the issuer.
reviews: u32Ratings received on the source.
rating_hundredths: u16Average of those ratings, in hundredths (487 is 4.87).
since: u64First completed trade on the source, a UTC day start.
created_at: u64When the issuer signed it.
expiration: u64When it stops being redeemable.
Implementations§
Source§impl ReputationAttestation
impl ReputationAttestation
Sourcepub fn rating(&self) -> f64
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.
Sourcepub fn rating_text(&self) -> String
pub fn rating_text(&self) -> String
Average rating as the event writes it, with two decimals.
Sourcepub fn build(
issuer: &Keys,
destination: &PublicKey,
subject: &str,
reviews: u32,
average: f64,
since: u64,
created_at: Timestamp,
lifetime: u64,
) -> Result<Event, AttestationError>
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.
Sourcepub fn parse(
event: &Event,
now: Timestamp,
max_lifetime: u64,
) -> Result<Self, AttestationError>
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.
Sourcepub fn parse_json(
json: &str,
now: Timestamp,
max_lifetime: u64,
) -> Result<(Self, Event), AttestationError>
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
impl Clone for ReputationAttestation
Source§impl Debug for ReputationAttestation
impl Debug for ReputationAttestation
impl Eq for ReputationAttestation
Source§impl From<&ReputationAttestation> for ReputationImport
impl From<&ReputationAttestation> for ReputationImport
Source§fn from(a: &ReputationAttestation) -> Self
fn from(a: &ReputationAttestation) -> Self
Source§impl PartialEq for ReputationAttestation
impl PartialEq for ReputationAttestation
impl StructuralPartialEq for ReputationAttestation
Auto Trait Implementations§
impl Freeze for ReputationAttestation
impl RefUnwindSafe for ReputationAttestation
impl Send for ReputationAttestation
impl Sync for ReputationAttestation
impl Unpin for ReputationAttestation
impl UnsafeUnpin for ReputationAttestation
impl UnwindSafe for ReputationAttestation
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
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