Struct prometheus_http_query::InstantVector
source · [−]pub struct InstantVector(pub String);
Expand description
An instant vector expression that can be further operated on with functions/aggregations or passed to a crate::Client in order to evaluate.
Tuple Fields
0: String
Implementations
sourceimpl InstantVector
impl InstantVector
sourcepub fn add(
self,
other: InstantVector,
match_modifier: Option<Match<'_>>,
group_modifier: Option<Group<'_>>
) -> Self
pub fn add(
self,
other: InstantVector,
match_modifier: Option<Match<'_>>,
group_modifier: Option<Group<'_>>
) -> Self
Add one instant vector to another. Additional modifiers (Match and Group) can be used to alter the matching behaviour between two instant vectors. See the Prometheus reference for details on this topic.
use prometheus_http_query::{Selector, InstantVector, Match, Error};
use std::convert::TryInto;
fn main() -> Result<(), Error> {
let one: InstantVector = Selector::new()
.metric("some_metric")
.with("some_label", "some_value")
.try_into()?;
let two: InstantVector = Selector::new()
.metric("other_metric")
.with("some_label", "some_value")
.with("other_label", "other_value")
.try_into()?;
let new = one.add(two, Some(Match::On(&["some_label"])), None);
// This would ultimately be the query string posted to the HTTP API.
let expected = r#"{__name__="some_metric",some_label="some_value"} + on (some_label) {__name__="other_metric",some_label="some_value",other_label="other_value"}"#;
assert_eq!(new.to_string(), expected.to_string());
Ok(())
}
sourcepub fn subtract(
self,
other: InstantVector,
match_modifier: Option<Match<'_>>,
group_modifier: Option<Group<'_>>
) -> Self
pub fn subtract(
self,
other: InstantVector,
match_modifier: Option<Match<'_>>,
group_modifier: Option<Group<'_>>
) -> Self
Subtract one instant vector from another. Additional modifiers (Match and Group) can be used to alter the matching behaviour between two instant vectors. See the Prometheus reference for details on this topic.
use prometheus_http_query::{Selector, InstantVector, Match, Error};
use std::convert::TryInto;
fn main() -> Result<(), Error> {
let one: InstantVector = Selector::new()
.metric("some_metric")
.with("some_label", "some_value")
.try_into()?;
let two: InstantVector = Selector::new()
.metric("other_metric")
.with("some_label", "some_value")
.with("other_label", "other_value")
.try_into()?;
let new = one.subtract(two, Some(Match::Ignoring(&["other_label"])), None);
// This would ultimately be the query string posted to the HTTP API.
let expected = r#"{__name__="some_metric",some_label="some_value"} - ignoring (other_label) {__name__="other_metric",some_label="some_value",other_label="other_value"}"#;
assert_eq!(new.to_string(), expected.to_string());
Ok(())
}
sourcepub fn multiply(
self,
other: InstantVector,
match_modifier: Option<Match<'_>>,
group_modifier: Option<Group<'_>>
) -> Self
pub fn multiply(
self,
other: InstantVector,
match_modifier: Option<Match<'_>>,
group_modifier: Option<Group<'_>>
) -> Self
Multiply one instant vector by another. Additional modifiers (Match and Group) can be used to alter the matching behaviour between two instant vectors. See the Prometheus reference for details on this topic.
use prometheus_http_query::{Selector, InstantVector, Match, Error};
use std::convert::TryInto;
fn main() -> Result<(), Error> {
let one: InstantVector = Selector::new()
.metric("some_metric")
.with("some_label", "some_value")
.try_into()?;
let two: InstantVector = Selector::new()
.metric("other_metric")
.with("some_label", "some_value")
.with("other_label", "other_value")
.try_into()?;
let new = one.multiply(two, Some(Match::On(&["some_label"])), None);
// This would ultimately be the query string posted to the HTTP API.
let expected = r#"{__name__="some_metric",some_label="some_value"} * on (some_label) {__name__="other_metric",some_label="some_value",other_label="other_value"}"#;
assert_eq!(new.to_string(), expected.to_string());
Ok(())
}
sourcepub fn divide(
self,
other: InstantVector,
match_modifier: Option<Match<'_>>,
group_modifier: Option<Group<'_>>
) -> Self
pub fn divide(
self,
other: InstantVector,
match_modifier: Option<Match<'_>>,
group_modifier: Option<Group<'_>>
) -> Self
Divide one instant vector by another. Additional modifiers (Match and Group) can be used to alter the matching behaviour between two instant vectors. See the Prometheus reference for details on this topic.
use prometheus_http_query::{Selector, InstantVector, Match, Error};
use std::convert::TryInto;
fn main() -> Result<(), Error> {
let one: InstantVector = Selector::new()
.metric("some_metric")
.with("some_label", "some_value")
.try_into()?;
let two: InstantVector = Selector::new()
.metric("other_metric")
.with("some_label", "some_value")
.with("other_label", "other_value")
.try_into()?;
let new = one.divide(two, Some(Match::Ignoring(&["other_label"])), None);
// This would ultimately be the query string posted to the HTTP API.
let expected = r#"{__name__="some_metric",some_label="some_value"} / ignoring (other_label) {__name__="other_metric",some_label="some_value",other_label="other_value"}"#;
assert_eq!(new.to_string(), expected.to_string());
Ok(())
}
sourcepub fn modulo(
self,
other: InstantVector,
match_modifier: Option<Match<'_>>,
group_modifier: Option<Group<'_>>
) -> Self
pub fn modulo(
self,
other: InstantVector,
match_modifier: Option<Match<'_>>,
group_modifier: Option<Group<'_>>
) -> Self
Divide one instant vector by another with remainder. Additional modifiers (Match and Group) can be used to alter the matching behaviour between two instant vectors. See the Prometheus reference for details on this topic.
use prometheus_http_query::{Selector, InstantVector, Match, Error};
use std::convert::TryInto;
fn main() -> Result<(), Error> {
let one: InstantVector = Selector::new()
.metric("some_metric")
.with("some_label", "some_value")
.try_into()?;
let two: InstantVector = Selector::new()
.metric("other_metric")
.with("some_label", "some_value")
.with("other_label", "other_value")
.try_into()?;
let new = one.modulo(two, Some(Match::Ignoring(&["other_label"])), None);
// This would ultimately be the query string posted to the HTTP API.
let expected = r#"{__name__="some_metric",some_label="some_value"} % ignoring (other_label) {__name__="other_metric",some_label="some_value",other_label="other_value"}"#;
assert_eq!(new.to_string(), expected.to_string());
Ok(())
}
sourcepub fn power(
self,
other: InstantVector,
match_modifier: Option<Match<'_>>,
group_modifier: Option<Group<'_>>
) -> Self
pub fn power(
self,
other: InstantVector,
match_modifier: Option<Match<'_>>,
group_modifier: Option<Group<'_>>
) -> Self
Exponentiate one instant vector by another. Additional modifiers (Match and Group) can be used to alter the matching behaviour between two instant vectors. See the Prometheus reference for details on this topic.
use prometheus_http_query::{Selector, InstantVector, Match, Error};
use std::convert::TryInto;
fn main() -> Result<(), Error> {
let one: InstantVector = Selector::new()
.metric("some_metric")
.with("some_label", "some_value")
.try_into()?;
let two: InstantVector = Selector::new()
.metric("other_metric")
.with("some_label", "some_value")
.with("other_label", "other_value")
.try_into()?;
let new = one.power(two, Some(Match::Ignoring(&["other_label"])), None);
// This would ultimately be the query string posted to the HTTP API.
let expected = r#"{__name__="some_metric",some_label="some_value"} ^ ignoring (other_label) {__name__="other_metric",some_label="some_value",other_label="other_value"}"#;
assert_eq!(new.to_string(), expected);
Ok(())
}
sourcepub fn and(self, other: InstantVector) -> Self
pub fn and(self, other: InstantVector) -> Self
Intersect two vectors so that the result vector consists of all elements of vector1 for which there are matching elements in vector2. See the Prometheus reference for details on this topic.
use prometheus_http_query::{Selector, InstantVector, Error};
use std::convert::TryInto;
fn main() -> Result<(), Error> {
let one: InstantVector = Selector::new()
.metric("some_metric")
.with("some_label", "some_value")
.try_into()?;
let two: InstantVector = Selector::new()
.metric("other_metric")
.with("some_label", "some_value")
.with("other_label", "other_value")
.try_into()?;
let new = one.and(two);
// This would ultimately be the query string posted to the HTTP API.
let expected = r#"{__name__="some_metric",some_label="some_value"} and {__name__="other_metric",some_label="some_value",other_label="other_value"}"#;
assert_eq!(new.to_string(), expected.to_string());
Ok(())
}
sourcepub fn or(self, other: InstantVector) -> Self
pub fn or(self, other: InstantVector) -> Self
Combine two vectors so that the result vector consists of all elements of vector1 and also all elements of vector2 which do not have matching label sets in vector1. See the Prometheus reference for details on this topic.
use prometheus_http_query::{Selector, InstantVector, Error};
use std::convert::TryInto;
fn main() -> Result<(), Error> {
let one: InstantVector = Selector::new()
.metric("some_metric")
.with("some_label", "some_value")
.try_into()?;
let two: InstantVector = Selector::new()
.metric("other_metric")
.with("some_label", "some_value")
.with("other_label", "other_value")
.try_into()?;
let new = one.or(two);
// This would ultimately be the query string posted to the HTTP API.
let expected = r#"{__name__="some_metric",some_label="some_value"} or {__name__="other_metric",some_label="some_value",other_label="other_value"}"#;
assert_eq!(new.to_string(), expected.to_string());
Ok(())
}
sourcepub fn unless(self, other: InstantVector) -> Self
pub fn unless(self, other: InstantVector) -> Self
Combine two vectors so that the result vector consists only of those elements of vector1 for which there are no matching elements in vector2. See the Prometheus reference for details on this topic.
use prometheus_http_query::{Selector, InstantVector, Error};
use std::convert::TryInto;
fn main() -> Result<(), Error> {
let one: InstantVector = Selector::new()
.metric("some_metric")
.with("some_label", "some_value")
.try_into()?;
let two: InstantVector = Selector::new()
.metric("other_metric")
.with("some_label", "some_value")
.with("other_label", "other_value")
.try_into()?;
let new = one.unless(two);
// This would ultimately be the query string posted to the HTTP API.
let expected = r#"{__name__="some_metric",some_label="some_value"} unless {__name__="other_metric",some_label="some_value",other_label="other_value"}"#;
assert_eq!(new.to_string(), expected.to_string());
Ok(())
}
sourcepub fn eq_vector(self, other: InstantVector, return_bool: bool) -> Self
pub fn eq_vector(self, other: InstantVector, return_bool: bool) -> Self
Apply the ==
operator to two vectors. Optionally set the bool
parameter
to modify the query result as per the PromQL documentation.
See the Prometheus reference
for details on comparison binary operators.
use prometheus_http_query::Selector;
use prometheus_http_query::InstantVector;
use std::convert::TryInto;
fn main() -> Result<(), prometheus_http_query::Error> {
let one: InstantVector = Selector::new()
.metric("some_metric")
.with("some_label", "some_value")
.try_into()?;
let two: InstantVector = Selector::new()
.metric("other_metric")
.with("some_label", "some_value")
.with("other_label", "other_value")
.try_into()?;
let new = one.eq_vector(two, false);
// This would ultimately be the query string posted to the HTTP API.
let expected = r#"{__name__="some_metric",some_label="some_value"} == {__name__="other_metric",some_label="some_value",other_label="other_value"}"#;
assert_eq!(new.to_string(), expected.to_string());
Ok(())
}
sourcepub fn ne_vector(self, other: InstantVector, return_bool: bool) -> Self
pub fn ne_vector(self, other: InstantVector, return_bool: bool) -> Self
Apply the !=
operator to two vectors. Optionally set the bool
parameter
to modify the query result as per the PromQL documentation.
See the Prometheus reference
for details on comparison binary operators.
use prometheus_http_query::Selector;
use prometheus_http_query::InstantVector;
use std::convert::TryInto;
fn main() -> Result<(), prometheus_http_query::Error> {
let one: InstantVector = Selector::new()
.metric("some_metric")
.with("some_label", "some_value")
.try_into()?;
let two: InstantVector = Selector::new()
.metric("other_metric")
.with("some_label", "some_value")
.with("other_label", "other_value")
.try_into()?;
let new = one.ne_vector(two, true);
// This would ultimately be the query string posted to the HTTP API.
let expected = r#"{__name__="some_metric",some_label="some_value"} != bool {__name__="other_metric",some_label="some_value",other_label="other_value"}"#;
assert_eq!(new.to_string(), expected.to_string());
Ok(())
}
sourcepub fn gt_vector(self, other: InstantVector, return_bool: bool) -> Self
pub fn gt_vector(self, other: InstantVector, return_bool: bool) -> Self
Apply the >
operator to two vectors. Optionally set the bool
parameter
to modify the query result as per the PromQL documentation.
See the Prometheus reference
for details on comparison binary operators.
use prometheus_http_query::Selector;
use prometheus_http_query::InstantVector;
use std::convert::TryInto;
fn main() -> Result<(), prometheus_http_query::Error> {
let one: InstantVector = Selector::new()
.metric("some_metric")
.with("some_label", "some_value")
.try_into()?;
let two: InstantVector = Selector::new()
.metric("other_metric")
.with("some_label", "some_value")
.with("other_label", "other_value")
.try_into()?;
let new = one.gt_vector(two, false);
// This would ultimately be the query string posted to the HTTP API.
let expected = r#"{__name__="some_metric",some_label="some_value"} > {__name__="other_metric",some_label="some_value",other_label="other_value"}"#;
assert_eq!(new.to_string(), expected.to_string());
Ok(())
}
sourcepub fn lt_vector(self, other: InstantVector, return_bool: bool) -> Self
pub fn lt_vector(self, other: InstantVector, return_bool: bool) -> Self
Apply the <
operator to two vectors. Optionally set the bool
parameter
to modify the query result as per the PromQL documentation.
See the Prometheus reference
for details on comparison binary operators.
use prometheus_http_query::Selector;
use prometheus_http_query::InstantVector;
use std::convert::TryInto;
fn main() -> Result<(), prometheus_http_query::Error> {
let one: InstantVector = Selector::new()
.metric("some_metric")
.with("some_label", "some_value")
.try_into()?;
let two: InstantVector = Selector::new()
.metric("other_metric")
.with("some_label", "some_value")
.with("other_label", "other_value")
.try_into()?;
let new = one.lt_vector(two, false);
// This would ultimately be the query string posted to the HTTP API.
let expected = r#"{__name__="some_metric",some_label="some_value"} < {__name__="other_metric",some_label="some_value",other_label="other_value"}"#;
assert_eq!(new.to_string(), expected.to_string());
Ok(())
}
sourcepub fn ge_vector(self, other: InstantVector, return_bool: bool) -> Self
pub fn ge_vector(self, other: InstantVector, return_bool: bool) -> Self
Apply the >=
operator to two vectors. Optionally set the bool
parameter
to modify the query result as per the PromQL documentation.
See the Prometheus reference
for details on comparison binary operators.
use prometheus_http_query::Selector;
use prometheus_http_query::InstantVector;
use std::convert::TryInto;
fn main() -> Result<(), prometheus_http_query::Error> {
let one: InstantVector = Selector::new()
.metric("some_metric")
.with("some_label", "some_value")
.try_into()?;
let two: InstantVector = Selector::new()
.metric("other_metric")
.with("some_label", "some_value")
.with("other_label", "other_value")
.try_into()?;
let new = one.ge_vector(two, false);
// This would ultimately be the query string posted to the HTTP API.
let expected = r#"{__name__="some_metric",some_label="some_value"} >= {__name__="other_metric",some_label="some_value",other_label="other_value"}"#;
assert_eq!(new.to_string(), expected.to_string());
Ok(())
}
sourcepub fn le_vector(self, other: InstantVector, return_bool: bool) -> Self
pub fn le_vector(self, other: InstantVector, return_bool: bool) -> Self
Apply the <=
operator to two vectors. Optionally set the bool
parameter
to modify the query result as per the PromQL documentation.
See the Prometheus reference
for details on comparison binary operators.
use prometheus_http_query::Selector;
use prometheus_http_query::InstantVector;
use std::convert::TryInto;
fn main() -> Result<(), prometheus_http_query::Error> {
let one: InstantVector = Selector::new()
.metric("some_metric")
.with("some_label", "some_value")
.try_into()?;
let two: InstantVector = Selector::new()
.metric("other_metric")
.with("some_label", "some_value")
.with("other_label", "other_value")
.try_into()?;
let new = one.le_vector(two, false);
// This would ultimately be the query string posted to the HTTP API.
let expected = r#"{__name__="some_metric",some_label="some_value"} <= {__name__="other_metric",some_label="some_value",other_label="other_value"}"#;
assert_eq!(new.to_string(), expected.to_string());
Ok(())
}
sourcepub fn eq_scalar(self, scalar: f64, return_bool: bool) -> Self
pub fn eq_scalar(self, scalar: f64, return_bool: bool) -> Self
Apply the ==
operator to a vector and a scalar. Optionally set the bool
parameter
to modify the query result as per the PromQL documentation.
See the Prometheus reference
for details on comparison binary operators.
use prometheus_http_query::Selector;
use prometheus_http_query::InstantVector;
use std::convert::TryInto;
fn main() -> Result<(), prometheus_http_query::Error> {
let one: InstantVector = Selector::new()
.metric("some_metric")
.with("some_label", "some_value")
.try_into()?;
let new = one.eq_scalar(8.5, true);
// This would ultimately be the query string posted to the HTTP API.
let expected = r#"{__name__="some_metric",some_label="some_value"} == bool 8.5"#;
assert_eq!(new.to_string(), expected.to_string());
Ok(())
}
sourcepub fn ne_scalar(self, scalar: f64, return_bool: bool) -> Self
pub fn ne_scalar(self, scalar: f64, return_bool: bool) -> Self
Apply the !=
operator to a vector and a scalar. Optionally set the bool
parameter
to modify the query result as per the PromQL documentation.
See the Prometheus reference
for details on comparison binary operators.
use prometheus_http_query::Selector;
use prometheus_http_query::InstantVector;
use std::convert::TryInto;
fn main() -> Result<(), prometheus_http_query::Error> {
let one: InstantVector = Selector::new()
.metric("some_metric")
.with("some_label", "some_value")
.try_into()?;
let new = one.ne_scalar(8.5, true);
// This would ultimately be the query string posted to the HTTP API.
let expected = r#"{__name__="some_metric",some_label="some_value"} != bool 8.5"#;
assert_eq!(new.to_string(), expected.to_string());
Ok(())
}
sourcepub fn gt_scalar(self, scalar: f64, return_bool: bool) -> Self
pub fn gt_scalar(self, scalar: f64, return_bool: bool) -> Self
Apply the >
operator to a vector and a scalar. Optionally set the bool
parameter
to modify the query result as per the PromQL documentation.
See the Prometheus reference
for details on comparison binary operators.
use prometheus_http_query::Selector;
use prometheus_http_query::InstantVector;
use std::convert::TryInto;
fn main() -> Result<(), prometheus_http_query::Error> {
let one: InstantVector = Selector::new()
.metric("some_metric")
.with("some_label", "some_value")
.try_into()?;
let new = one.gt_scalar(8.5, false);
// This would ultimately be the query string posted to the HTTP API.
let expected = r#"{__name__="some_metric",some_label="some_value"} > 8.5"#;
assert_eq!(new.to_string(), expected.to_string());
Ok(())
}
sourcepub fn lt_scalar(self, scalar: f64, return_bool: bool) -> Self
pub fn lt_scalar(self, scalar: f64, return_bool: bool) -> Self
Apply the <
operator to a vector and a scalar. Optionally set the bool
parameter
to modify the query result as per the PromQL documentation.
See the Prometheus reference
for details on comparison binary operators.
use prometheus_http_query::Selector;
use prometheus_http_query::InstantVector;
use std::convert::TryInto;
fn main() -> Result<(), prometheus_http_query::Error> {
let one: InstantVector = Selector::new()
.metric("some_metric")
.with("some_label", "some_value")
.try_into()?;
let new = one.lt_scalar(8.5, false);
// This would ultimately be the query string posted to the HTTP API.
let expected = r#"{__name__="some_metric",some_label="some_value"} < 8.5"#;
assert_eq!(new.to_string(), expected.to_string());
Ok(())
}
sourcepub fn ge_scalar(self, scalar: f64, return_bool: bool) -> Self
pub fn ge_scalar(self, scalar: f64, return_bool: bool) -> Self
Apply the >=
operator to a vector and a scalar. Optionally set the bool
parameter
to modify the query result as per the PromQL documentation.
See the Prometheus reference
for details on comparison binary operators.
use prometheus_http_query::Selector;
use prometheus_http_query::InstantVector;
use std::convert::TryInto;
fn main() -> Result<(), prometheus_http_query::Error> {
let one: InstantVector = Selector::new()
.metric("some_metric")
.with("some_label", "some_value")
.try_into()?;
let new = one.ge_scalar(8.5, false);
// This would ultimately be the query string posted to the HTTP API.
let expected = r#"{__name__="some_metric",some_label="some_value"} >= 8.5"#;
assert_eq!(new.to_string(), expected.to_string());
Ok(())
}
sourcepub fn le_scalar(self, scalar: f64, return_bool: bool) -> Self
pub fn le_scalar(self, scalar: f64, return_bool: bool) -> Self
Apply the <=
operator to a vector and a scalar. Optionally set the bool
parameter
to modify the query result as per the PromQL documentation.
See the Prometheus reference
for details on comparison binary operators.
use prometheus_http_query::Selector;
use prometheus_http_query::InstantVector;
use std::convert::TryInto;
fn main() -> Result<(), prometheus_http_query::Error> {
let one: InstantVector = Selector::new()
.metric("some_metric")
.with("some_label", "some_value")
.try_into()?;
let new = one.le_scalar(8.5, false);
// This would ultimately be the query string posted to the HTTP API.
let expected = r#"{__name__="some_metric",some_label="some_value"} <= 8.5"#;
assert_eq!(new.to_string(), expected.to_string());
Ok(())
}
Trait Implementations
sourceimpl Add<f64> for InstantVector
impl Add<f64> for InstantVector
sourcefn add(self, scalar: f64) -> Self
fn add(self, scalar: f64) -> Self
Add a scalar value to every data sample in a vector.
use prometheus_http_query::{Selector, InstantVector, Error};
use std::convert::TryInto;
fn main() -> Result<(), Error> {
let v: InstantVector = Selector::new()
.metric("some_metric")
.with("some_label", "some_value")
.try_into()?;
let v = v + 4.0;
assert_eq!(v.to_string(), String::from("{__name__=\"some_metric\",some_label=\"some_value\"} + 4"));
Ok(())
}
type Output = Self
type Output = Self
The resulting type after applying the +
operator.
sourceimpl BitXor<f64> for InstantVector
impl BitXor<f64> for InstantVector
sourcefn bitxor(self, scalar: f64) -> Self
fn bitxor(self, scalar: f64) -> Self
Exponentiate each data sample in a vector by a scalar value.
use prometheus_http_query::{Selector, InstantVector, Error};
use std::convert::TryInto;
fn main() -> Result<(), Error> {
let v: InstantVector = Selector::new()
.metric("some_metric")
.with("some_label", "some_value")
.try_into()?;
let v = v ^ 2.0;
assert_eq!(v.to_string(), String::from("{__name__=\"some_metric\",some_label=\"some_value\"} ^ 2"));
Ok(())
}
type Output = Self
type Output = Self
The resulting type after applying the ^
operator.
sourceimpl Debug for InstantVector
impl Debug for InstantVector
sourceimpl Display for InstantVector
impl Display for InstantVector
sourceimpl Div<f64> for InstantVector
impl Div<f64> for InstantVector
sourcefn div(self, scalar: f64) -> Self
fn div(self, scalar: f64) -> Self
Divide each data sample in a vector by a scalar value.
use prometheus_http_query::{Selector, InstantVector, Error};
use std::convert::TryInto;
fn main() -> Result<(), Error> {
let v: InstantVector = Selector::new()
.metric("some_metric")
.with("some_label", "some_value")
.try_into()?;
let v = v / 2.0;
assert_eq!(v.to_string(), String::from("{__name__=\"some_metric\",some_label=\"some_value\"} / 2"));
Ok(())
}
type Output = Self
type Output = Self
The resulting type after applying the /
operator.
sourceimpl Mul<f64> for InstantVector
impl Mul<f64> for InstantVector
sourcefn mul(self, scalar: f64) -> Self
fn mul(self, scalar: f64) -> Self
Multiply each data sample in a vector by a scalar value.
use prometheus_http_query::{Selector, InstantVector, Error};
use std::convert::TryInto;
fn main() -> Result<(), Error> {
let v: InstantVector = Selector::new()
.metric("some_metric")
.with("some_label", "some_value")
.try_into()?;
let v = v * 2.0;
assert_eq!(v.to_string(), String::from("{__name__=\"some_metric\",some_label=\"some_value\"} * 2"));
Ok(())
}
type Output = Self
type Output = Self
The resulting type after applying the *
operator.
sourceimpl PartialEq<InstantVector> for InstantVector
impl PartialEq<InstantVector> for InstantVector
sourcefn eq(&self, other: &InstantVector) -> bool
fn eq(&self, other: &InstantVector) -> bool
This method tests for self
and other
values to be equal, and is used
by ==
. Read more
sourcefn ne(&self, other: &InstantVector) -> bool
fn ne(&self, other: &InstantVector) -> bool
This method tests for !=
.
sourceimpl Rem<f64> for InstantVector
impl Rem<f64> for InstantVector
sourcefn rem(self, scalar: f64) -> Self
fn rem(self, scalar: f64) -> Self
Divide each data sample in a vector by a scalar value with remainder.
use prometheus_http_query::{Selector, InstantVector, Error};
use std::convert::TryInto;
fn main() -> Result<(), Error> {
let v: InstantVector = Selector::new()
.metric("some_metric")
.with("some_label", "some_value")
.try_into()?;
let v = v % 2.0;
assert_eq!(v.to_string(), String::from("{__name__=\"some_metric\",some_label=\"some_value\"} % 2"));
Ok(())
}
type Output = Self
type Output = Self
The resulting type after applying the %
operator.
sourceimpl Sub<f64> for InstantVector
impl Sub<f64> for InstantVector
sourcefn sub(self, scalar: f64) -> Self
fn sub(self, scalar: f64) -> Self
Subtract a scalar value from every data sample in a vector.
use prometheus_http_query::{Selector, InstantVector, Error};
use std::convert::TryInto;
fn main() -> Result<(), Error> {
let v: InstantVector = Selector::new()
.metric("some_metric")
.with("some_label", "some_value")
.try_into()?;
let v = v - 4.5;
assert_eq!(v.to_string(), String::from("{__name__=\"some_metric\",some_label=\"some_value\"} - 4.5"));
Ok(())
}
type Output = Self
type Output = Self
The resulting type after applying the -
operator.
sourceimpl TryFrom<Selector<'_>> for InstantVector
impl TryFrom<Selector<'_>> for InstantVector
sourcefn try_from(selector: Selector<'_>) -> Result<Self, Self::Error>
fn try_from(selector: Selector<'_>) -> Result<Self, Self::Error>
Convert a Selector to an InstantVector.
use prometheus_http_query::{Selector, InstantVector, Error};
use std::convert::TryInto;
fn main() -> Result<(), Error> {
let v: Result<InstantVector, Error> = Selector::new()
.metric("some_metric")
.try_into();
assert!(v.is_ok());
Ok(())
}
impl StructuralPartialEq for InstantVector
Auto Trait Implementations
impl RefUnwindSafe for InstantVector
impl Send for InstantVector
impl Sync for InstantVector
impl Unpin for InstantVector
impl UnwindSafe for InstantVector
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<T> Instrument for T
impl<T> Instrument for T
sourcefn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
sourcefn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
sourceimpl<T> WithSubscriber for T
impl<T> WithSubscriber for T
sourcefn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> where
S: Into<Dispatch>,
fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> where
S: Into<Dispatch>,
Attaches the provided Subscriber
to this type, returning a
WithDispatch
wrapper. Read more
sourcefn with_current_subscriber(self) -> WithDispatch<Self>
fn with_current_subscriber(self) -> WithDispatch<Self>
Attaches the current default Subscriber
to this type, returning a
WithDispatch
wrapper. Read more