pub struct PartialPowerAverage { /* private fields */ }Expand description
Power average that is not deemed complete
Implementations§
Source§impl PartialPowerAverage
impl PartialPowerAverage
pub fn new(power_average: PowerAverage, duration_secs: u16) -> Self
pub fn power_average(&self) -> PowerAverage
pub fn duration_secs(&self) -> u16
pub fn covers(&self, ts: DateTime<Utc>, secs: u16) -> bool
Sourcepub fn cover_percentage(&self, ts: DateTime<Utc>, num_secs: u32) -> u8
pub fn cover_percentage(&self, ts: DateTime<Utc>, num_secs: u32) -> u8
Calculates what percentage of a given time range is covered by this partial power average.
This method computes the overlap between the partial power average’s time range
[self.start(), self.end()] and the query time range [ts, ts + num_secs].
§Arguments
ts- The start timestamp of the query range (in UTC)num_secs- The duration of the query range in seconds
§Returns
A percentage (0-100) representing how much of the query range is covered by this partial power average. Returns 0 if there is no overlap.
§Examples
// If partial average covers 10:00-11:00 (3600 seconds)
// and query is 10:15-10:45 (1800 seconds)
// Result is 100% (query range completely within partial average)
// If partial average covers 10:00-11:00
// and query is 10:30-11:30 (3600 seconds)
// Result is 50% (1800 seconds overlap out of 3600 seconds query)Trait Implementations§
Source§impl Clone for PartialPowerAverage
impl Clone for PartialPowerAverage
Source§fn clone(&self) -> PartialPowerAverage
fn clone(&self) -> PartialPowerAverage
Returns a duplicate of the value. Read more
1.0.0 · 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 PartialPowerAverage
impl Debug for PartialPowerAverage
impl Copy for PartialPowerAverage
Auto Trait Implementations§
impl Freeze for PartialPowerAverage
impl RefUnwindSafe for PartialPowerAverage
impl Send for PartialPowerAverage
impl Sync for PartialPowerAverage
impl Unpin for PartialPowerAverage
impl UnwindSafe for PartialPowerAverage
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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