pub struct EntityBandwidth {
pub entity_id: String,
pub total_request_bytes: u64,
pub total_response_bytes: u64,
pub total_request_count: u64,
pub first_seen: Instant,
pub last_seen: Instant,
pub access_count: u64,
/* private fields */
}Expand description
Bandwidth tracking for a single entity (IP).
Fields§
§entity_id: StringEntity identifier (usually IP address)
total_request_bytes: u64Total request bytes
total_response_bytes: u64Total response bytes
total_request_count: u64Total request count
first_seen: InstantFirst seen timestamp
last_seen: InstantLast seen timestamp
access_count: u64Access counter for LRU
Implementations§
Source§impl EntityBandwidth
impl EntityBandwidth
Sourcepub fn new(
entity_id: String,
bucket_duration_ms: u64,
max_buckets: usize,
) -> Self
pub fn new( entity_id: String, bucket_duration_ms: u64, max_buckets: usize, ) -> Self
Create new bandwidth tracking for an entity.
Sourcepub fn record(&mut self, request_bytes: u64, response_bytes: u64)
pub fn record(&mut self, request_bytes: u64, response_bytes: u64)
Record a request/response pair.
Sourcepub fn avg_bytes_per_minute(&self) -> u64
pub fn avg_bytes_per_minute(&self) -> u64
Get average bytes per minute from recent buckets.
Sourcepub fn current_bytes_per_minute(&self) -> u64
pub fn current_bytes_per_minute(&self) -> u64
Get current bytes per minute (from current bucket).
Sourcepub fn total_bytes(&self) -> u64
pub fn total_bytes(&self) -> u64
Get total bytes.
Sourcepub fn recent_buckets(&self) -> Vec<BandwidthBucket>
pub fn recent_buckets(&self) -> Vec<BandwidthBucket>
Get recent buckets as snapshots.
Trait Implementations§
Source§impl From<&EntityBandwidth> for EntityBandwidthSnapshot
impl From<&EntityBandwidth> for EntityBandwidthSnapshot
Source§fn from(entity: &EntityBandwidth) -> Self
fn from(entity: &EntityBandwidth) -> Self
Converts to this type from the input type.
Auto Trait Implementations§
impl Freeze for EntityBandwidth
impl RefUnwindSafe for EntityBandwidth
impl Send for EntityBandwidth
impl Sync for EntityBandwidth
impl Unpin for EntityBandwidth
impl UnsafeUnpin for EntityBandwidth
impl UnwindSafe for EntityBandwidth
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> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Convert
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Convert
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
Convert
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
Convert
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.Source§impl<T> DowncastSync for T
impl<T> DowncastSync for T
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