use std::fmt::Debug;
use std::hash::Hash;
use crate::field::{LogFieldSelector, MetricFieldSelector, TraceFieldSelector};
use crate::registry::PolicySnapshot;
use super::compiled::CompiledMatchers;
pub trait Signal: 'static {
type FieldSelector: Clone + Eq + Hash + Debug;
fn compiled_matchers(snapshot: &PolicySnapshot) -> Option<&CompiledMatchers<Self>>
where
Self: Sized;
}
#[derive(Debug)]
pub struct LogSignal;
impl Signal for LogSignal {
type FieldSelector = LogFieldSelector;
fn compiled_matchers(snapshot: &PolicySnapshot) -> Option<&CompiledMatchers<Self>> {
snapshot.compiled_log_matchers()
}
}
#[derive(Debug)]
pub struct MetricSignal;
impl Signal for MetricSignal {
type FieldSelector = MetricFieldSelector;
fn compiled_matchers(snapshot: &PolicySnapshot) -> Option<&CompiledMatchers<Self>> {
snapshot.compiled_metric_matchers()
}
}
#[derive(Debug)]
pub struct TraceSignal;
impl Signal for TraceSignal {
type FieldSelector = TraceFieldSelector;
fn compiled_matchers(snapshot: &PolicySnapshot) -> Option<&CompiledMatchers<Self>> {
snapshot.compiled_trace_matchers()
}
}