pub struct VectorSelector {
pub name: Option<String>,
pub matchers: Vec<LabelMatcher>,
pub offset: Option<Duration>,
pub at: Option<AtModifier>,
}Expand description
A vector selector expression (instant vector).
Selects a set of time series with a single sample value for each at the query evaluation time.
§Example
use rusty_promql_parser::parser::selector::{VectorSelector, LabelMatcher, LabelMatchOp};
let mut sel = VectorSelector::new("http_requests_total");
sel.add_matcher(LabelMatcher::new("job", LabelMatchOp::Equal, "api"));
assert_eq!(sel.to_string(), r#"http_requests_total{job="api"}"#);Fields§
§name: Option<String>Metric name (optional if label matchers include __name__).
matchers: Vec<LabelMatcher>Label matchers.
offset: Option<Duration>Offset modifier (e.g., offset 5m, offset -1h).
at: Option<AtModifier>@ modifier for timestamp pinning.
Implementations§
Source§impl VectorSelector
impl VectorSelector
Sourcepub fn new(name: impl Into<String>) -> Self
pub fn new(name: impl Into<String>) -> Self
Create a new vector selector with just a metric name
Sourcepub fn with_matchers(matchers: Vec<LabelMatcher>) -> Self
pub fn with_matchers(matchers: Vec<LabelMatcher>) -> Self
Create a new vector selector with only label matchers
Sourcepub fn add_matcher(&mut self, matcher: LabelMatcher)
pub fn add_matcher(&mut self, matcher: LabelMatcher)
Add a label matcher
Sourcepub fn all_matchers(&self) -> Vec<LabelMatcher>
pub fn all_matchers(&self) -> Vec<LabelMatcher>
Get all matchers including the implicit name matcher
Sourcepub fn has_non_empty_matcher(&self) -> bool
pub fn has_non_empty_matcher(&self) -> bool
Check if this selector has at least one non-empty matcher (Required for valid selectors to avoid selecting all series)
Trait Implementations§
Source§impl Clone for VectorSelector
impl Clone for VectorSelector
Source§fn clone(&self) -> VectorSelector
fn clone(&self) -> VectorSelector
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 VectorSelector
impl Debug for VectorSelector
Source§impl Display for VectorSelector
impl Display for VectorSelector
Source§impl PartialEq for VectorSelector
impl PartialEq for VectorSelector
impl StructuralPartialEq for VectorSelector
Auto Trait Implementations§
impl Freeze for VectorSelector
impl RefUnwindSafe for VectorSelector
impl Send for VectorSelector
impl Sync for VectorSelector
impl Unpin for VectorSelector
impl UnwindSafe for VectorSelector
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