pub struct EndpointProfile {
pub template: String,
pub payload_size: Distribution,
pub response_size: Distribution,
pub expected_params: HashMap<String, ParamStats>,
pub content_types: HashMap<String, u32>,
pub response_content_types: HashMap<String, u32>,
pub status_codes: HashMap<u16, u32>,
pub request_rate: RateTracker,
pub endpoint_risk: f32,
pub sample_count: u32,
pub first_seen_ms: u64,
pub last_updated_ms: u64,
}Expand description
Statistical profile for a single API endpoint.
Memory budget: ~2KB per endpoint
Fields§
§template: StringPath template (e.g., “/api/users/{id}”)
payload_size: DistributionPayload size distribution (bytes)
response_size: DistributionResponse size distribution (bytes)
expected_params: HashMap<String, ParamStats>Expected query parameters (name -> stats) Capped at MAX_PARAMS parameters
content_types: HashMap<String, u32>Expected content types (type -> frequency count)
response_content_types: HashMap<String, u32>Expected response content types (type -> frequency count)
status_codes: HashMap<u16, u32>HTTP status codes (code -> count)
request_rate: RateTrackerRequest rate tracker (60-second window)
endpoint_risk: f32Aggregate endpoint risk score (0.0-100.0) Computed from attack density and vulnerability indicators
sample_count: u32Total sample count
first_seen_ms: u64First seen timestamp (ms)
last_updated_ms: u64Last updated timestamp (ms)
Implementations§
Source§impl EndpointProfile
impl EndpointProfile
Sourcepub fn new(template: String, now_ms: u64) -> Self
pub fn new(template: String, now_ms: u64) -> Self
Create a new profile for an endpoint template.
Sourcepub fn update(
&mut self,
payload_size: usize,
params: &[(&str, &str)],
content_type: Option<&str>,
now_ms: u64,
)
pub fn update( &mut self, payload_size: usize, params: &[(&str, &str)], content_type: Option<&str>, now_ms: u64, )
Update profile with request data.
Uses &[(&str, &str)] to pass param name and value.
Sourcepub fn update_response(
&mut self,
response_size: usize,
status_code: u16,
content_type: Option<&str>,
now_ms: u64,
)
pub fn update_response( &mut self, response_size: usize, status_code: u16, content_type: Option<&str>, now_ms: u64, )
Update profile with response data.
Sourcepub fn record_status(&mut self, status_code: u16)
pub fn record_status(&mut self, status_code: u16)
Record response status code.
Sourcepub fn dominant_content_type(&self) -> Option<&str>
pub fn dominant_content_type(&self) -> Option<&str>
Get the dominant content type (most frequent).
Sourcepub fn dominant_response_content_type(&self) -> Option<&str>
pub fn dominant_response_content_type(&self) -> Option<&str>
Get the dominant response content type.
Sourcepub fn param_frequency(&self, param: &str) -> f64
pub fn param_frequency(&self, param: &str) -> f64
Get parameter frequency (0.0-1.0).
Sourcepub fn is_expected_param(&self, param: &str, threshold: f64) -> bool
pub fn is_expected_param(&self, param: &str, threshold: f64) -> bool
Check if a parameter is “expected” (seen in > threshold of requests).
Sourcepub fn status_frequency(&self, status_code: u16) -> f64
pub fn status_frequency(&self, status_code: u16) -> f64
Get status code frequency (0.0-1.0).
Sourcepub fn error_rate(&self) -> f64
pub fn error_rate(&self) -> f64
Get the error rate (4xx + 5xx responses).
Sourcepub fn baseline_rate(&self, now_ms: u64) -> f64
pub fn baseline_rate(&self, now_ms: u64) -> f64
Calculate baseline request rate (requests per minute over lifetime).
Trait Implementations§
Source§impl Clone for EndpointProfile
impl Clone for EndpointProfile
Source§fn clone(&self) -> EndpointProfile
fn clone(&self) -> EndpointProfile
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for EndpointProfile
impl Debug for EndpointProfile
Source§impl<'de> Deserialize<'de> for EndpointProfile
impl<'de> Deserialize<'de> for EndpointProfile
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Auto Trait Implementations§
impl Freeze for EndpointProfile
impl RefUnwindSafe for EndpointProfile
impl Send for EndpointProfile
impl Sync for EndpointProfile
impl Unpin for EndpointProfile
impl UnsafeUnpin for EndpointProfile
impl UnwindSafe for EndpointProfile
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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>
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>
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)
&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)
&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>
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>
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