pub struct BillingBlockManager { /* private fields */ }Expand description
Manager for billing block tracking
Implementations§
Source§impl BillingBlockManager
impl BillingBlockManager
pub fn new() -> Self
Sourcepub fn add_usage(
&mut self,
timestamp: &DateTime<Utc>,
input_tokens: u64,
output_tokens: u64,
cache_creation_tokens: u64,
cache_read_tokens: u64,
cost: f64,
)
pub fn add_usage( &mut self, timestamp: &DateTime<Utc>, input_tokens: u64, output_tokens: u64, cache_creation_tokens: u64, cache_read_tokens: u64, cost: f64, )
Add usage to a billing block
Sourcepub fn get_usage(&self, block: &BillingBlock) -> Option<&BillingBlockUsage>
pub fn get_usage(&self, block: &BillingBlock) -> Option<&BillingBlockUsage>
Get usage for a specific billing block
Sourcepub fn get_all_blocks(&self) -> Vec<(BillingBlock, BillingBlockUsage)>
pub fn get_all_blocks(&self) -> Vec<(BillingBlock, BillingBlockUsage)>
Get all blocks sorted by date and block_hour
Sourcepub fn get_blocks_for_date(
&self,
date: NaiveDate,
) -> Vec<(BillingBlock, BillingBlockUsage)>
pub fn get_blocks_for_date( &self, date: NaiveDate, ) -> Vec<(BillingBlock, BillingBlockUsage)>
Get blocks for a specific date
Sourcepub fn get_color_for_cost(cost: f64) -> &'static str
pub fn get_color_for_cost(cost: f64) -> &'static str
Get color coding for a block based on cost thresholds
- Green: < $2.5
- Yellow: < $5.0
- Red: >= $5.0
Trait Implementations§
Source§impl Debug for BillingBlockManager
impl Debug for BillingBlockManager
Source§impl Default for BillingBlockManager
impl Default for BillingBlockManager
Source§fn default() -> BillingBlockManager
fn default() -> BillingBlockManager
Returns the “default value” for a type. Read more
Auto Trait Implementations§
impl Freeze for BillingBlockManager
impl RefUnwindSafe for BillingBlockManager
impl Send for BillingBlockManager
impl Sync for BillingBlockManager
impl Unpin for BillingBlockManager
impl UnwindSafe for BillingBlockManager
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