From 09b8a8d57cb1545f2b207701bf6d0bcaa4761183 Mon Sep 17 00:00:00 2001 From: Maaz Ahmed <maaz.a@subcom.tech> Date: Tue, 7 May 2024 10:57:08 +0000 Subject: [PATCH] feat: impl Deserialize on custom types in utils --- .gitlab-ci.yml | 15 +++++---------- Cargo.lock | 2 +- Cargo.toml | 2 +- src/utils.rs | 5 +++-- 4 files changed, 10 insertions(+), 14 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index a79242d..69cebc3 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -3,17 +3,18 @@ stages: - test - publish -build: +default: tags: - linux + - docker + +build: stage: build image: rust:latest script: - cargo build rustdoc: - tags: - - linux stage: build image: rust:latest script: @@ -23,16 +24,12 @@ rustdoc: - target/doc unit-test: - tags: - - linux stage: test image: rust:latest script: - cargo test --lib lint-test: - tags: - - linux stage: test image: rust:latest script: @@ -40,8 +37,6 @@ lint-test: - cargo clippy docs: - tags: - - linux stage: publish image: alpine dependencies: @@ -53,4 +48,4 @@ docs: paths: - public only: - - master \ No newline at end of file + - master diff --git a/Cargo.lock b/Cargo.lock index d6117f5..8a83a84 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -637,7 +637,7 @@ dependencies = [ [[package]] name = "mquery" -version = "0.8.1" +version = "0.8.2" dependencies = [ "enum-as-inner", "mquery-macros", diff --git a/Cargo.toml b/Cargo.toml index b560629..2c5e95e 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "mquery" -version = "0.8.1" +version = "0.8.2" edition = "2021" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html diff --git a/src/utils.rs b/src/utils.rs index c47ccd3..ad9c708 100644 --- a/src/utils.rs +++ b/src/utils.rs @@ -5,7 +5,7 @@ use prometheus_http_query::response::{InstantVector, RangeVector, Sample}; use rayon::prelude::*; -use serde::de::DeserializeOwned; +use serde::{de::DeserializeOwned, Deserialize}; use std::collections::HashMap; /// Helper trait for bulk type conversion of query result data @@ -99,7 +99,7 @@ pub fn convert_labels<T: DeserializeOwned>( /// This can be used directly to convert an [`InstantVector`] using `try_from` with type hinting, /// or use the [`Convert`] trait for bulk conversion of type `Vec<InstantVector>`. /// See the trait level docs for [`Convert`] for more information. -#[derive(Clone, Debug)] +#[derive(Clone, Debug, Deserialize)] pub struct CustomInstantVec<M> { pub labels: M, pub sample: Sample, @@ -122,6 +122,7 @@ impl<M: DeserializeOwned> TryFrom<InstantVector> for CustomInstantVec<M> { /// This can be used directly to convert a [`RangeVector`] using `try_from` with type hinting, /// or use the [`Convert`] trait for bulk conversion of type `Vec<InstantVector>`. /// See the trait level docs for [`Convert`] for more information. +#[derive(Clone, Debug, Deserialize)] pub struct CustomRangeVec<M> { pub labels: M, pub samples: Vec<Sample>, -- GitLab