pub struct IdentityLedger { /* private fields */ }Expand description
In-memory attribution ledger grouped by the strongest available identity key.
Implementations§
Source§impl IdentityLedger
impl IdentityLedger
Sourcepub fn record(
&mut self,
identity: &CallerIdentity,
consumed: usize,
saved: usize,
accepted: bool,
)
pub fn record( &mut self, identity: &CallerIdentity, consumed: usize, saved: usize, accepted: bool, )
Records token usage, savings, and outcome acceptance for a caller.
Sourcepub fn attribution_for(&self, key: &str) -> Option<&IdentityAttribution>
pub fn attribution_for(&self, key: &str) -> Option<&IdentityAttribution>
Returns attribution recorded under an identity key.
Sourcepub fn top_consumers(&self, limit: usize) -> Vec<&IdentityAttribution>
pub fn top_consumers(&self, limit: usize) -> Vec<&IdentityAttribution>
Returns up to limit entries ordered by descending token consumption.
Sourcepub fn top_savers(&self, limit: usize) -> Vec<&IdentityAttribution>
pub fn top_savers(&self, limit: usize) -> Vec<&IdentityAttribution>
Returns up to limit entries ordered by descending token savings.
Sourcepub fn total_tokens(&self) -> usize
pub fn total_tokens(&self) -> usize
Returns total tokens consumed across all identities.
Sourcepub fn total_savings(&self) -> usize
pub fn total_savings(&self) -> usize
Returns total tokens saved across all identities.
Sourcepub fn summary(&self) -> IdentityLedgerSummary
pub fn summary(&self) -> IdentityLedgerSummary
Summarizes distinct identities and aggregate token efficiency.
Trait Implementations§
Source§impl Clone for IdentityLedger
impl Clone for IdentityLedger
Source§fn clone(&self) -> IdentityLedger
fn clone(&self) -> IdentityLedger
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for IdentityLedger
impl Debug for IdentityLedger
Source§impl Default for IdentityLedger
impl Default for IdentityLedger
Source§fn default() -> IdentityLedger
fn default() -> IdentityLedger
Returns the “default value” for a type. Read more
Auto Trait Implementations§
impl Freeze for IdentityLedger
impl RefUnwindSafe for IdentityLedger
impl Send for IdentityLedger
impl Sync for IdentityLedger
impl Unpin for IdentityLedger
impl UnsafeUnpin for IdentityLedger
impl UnwindSafe for IdentityLedger
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
Mutably borrows from an owned value. Read more
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,
impl<A, B, T> HttpServerConnExec<A, B> for Twhere
B: Body,
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>
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 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>
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