Struct AwardReport

Source
pub struct AwardReport {
    pub requested_xp: u64,
    pub accepted_xp: u64,
    pub discarded_xp: u64,
    pub saturated: bool,
    pub level_before: u16,
    pub level_after: u16,
    pub promotions: u16,
    pub xp_before: u64,
    pub xp_spent: u64,
    pub xp_after: u64,
    pub at_cap: bool,
}
Expand description

Exact result of applying the legacy saturating-add-then-promote rule.

Preview and commit return the same value if no state changes between them. Copies of reports are observations, not single-use reward tokens. Only the report returned by a new accepted award should drive rewards.

Using u128 arithmetic, xp_before + accepted_xp == xp_spent + xp_after. accepted_xp is the delta admitted by the initial saturating addition, not xp_after - xp_before, which may be negative after promotion costs.

Fields§

§requested_xp: u64

XP requested by the caller.

§accepted_xp: u64

XP admitted before promotion subtraction; at most u64::MAX - xp_before.

§discarded_xp: u64

Requested XP discarded by saturation, even if promotions free room later.

§saturated: bool

Whether any requested XP was discarded. Exactly filling storage is false.

§level_before: u16

Level before this award.

§level_after: u16

Level after this award.

§promotions: u16

New promotions, bounded by 1023; zero when already at the cap.

§xp_before: u64

Retained XP before the initial addition.

§xp_spent: u64

Total XP subtracted for newly earned levels (not a lifetime total).

§xp_after: u64

Retained remainder after promotion subtraction; may be large at the cap.

§at_cap: bool

Whether level_after equals the authored maximum, including maximum 1.

Trait Implementations§

Source§

impl Clone for AwardReport

Source§

fn clone(&self) -> AwardReport

Returns a duplicate of the value. Read more
1.0.0 · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Debug for AwardReport

Source§

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

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

impl PartialEq for AwardReport

Source§

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

Tests for self and other values to be equal, and is used by ==.
1.0.0 · 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 Copy for AwardReport

Source§

impl Eq for AwardReport

Source§

impl StructuralPartialEq for AwardReport

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.