Enum prometheus_http_query::response::Data
source · pub enum Data {
Vector(Vec<InstantVector>),
Matrix(Vec<RangeVector>),
Scalar(Sample),
}
Expand description
A wrapper for possible result types of expression queries (crate::Client::query and crate::Client::query_range).
Variants§
Implementations§
source§impl Data
impl Data
sourcepub fn as_vector(&self) -> Option<&[InstantVector]>
pub fn as_vector(&self) -> Option<&[InstantVector]>
If the result type of the query is vector
, returns an array of InstantVectors. Returns None
otherwise.
sourcepub fn as_matrix(&self) -> Option<&[RangeVector]>
pub fn as_matrix(&self) -> Option<&[RangeVector]>
If the result type of the query is matrix
returns an array of RangeVectors. Returns None
otherwise.
sourcepub fn as_scalar(&self) -> Option<&Sample>
pub fn as_scalar(&self) -> Option<&Sample>
If the result type of the query is scalar
, returns a single Sample. Returns None
otherwise.
sourcepub fn is_vector(&self) -> bool
pub fn is_vector(&self) -> bool
Check if this PromqlResult contains a list of InstantVectors (i.e. result type vector
).
sourcepub fn is_matrix(&self) -> bool
pub fn is_matrix(&self) -> bool
Check if this PromqlResult contains a list of RangeVectors (i.e. result type matrix
).
sourcepub fn is_scalar(&self) -> bool
pub fn is_scalar(&self) -> bool
Check if this PromqlResult contains a scalar value (i.e. result type scalar
, a single Sample).
Trait Implementations§
source§impl<'de> Deserialize<'de> for Data
impl<'de> Deserialize<'de> for Data
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>,
Deserialize this value from the given Serde deserializer. Read more
Auto Trait Implementations§
impl RefUnwindSafe for Data
impl Send for Data
impl Sync for Data
impl Unpin for Data
impl UnwindSafe for Data
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