Skip to content

Commit 59cd15c

Browse files
committed
refactor: [torrust#1403] move types
1 parent 5a168aa commit 59cd15c

File tree

3 files changed

+19
-14
lines changed

3 files changed

+19
-14
lines changed
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
use serde::Serialize;
2+
3+
use super::LabelName;
4+
5+
#[derive(Debug, Clone, Eq, PartialEq, Default, Serialize, Ord, PartialOrd)]
6+
pub struct LabelNameSet {
7+
values: Vec<LabelName>,
8+
}
9+
10+
impl From<Vec<LabelName>> for LabelNameSet {
11+
fn from(values: Vec<LabelName>) -> Self {
12+
Self { values }
13+
}
14+
}

packages/primitives/src/metrics/label_set.rs

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,8 @@ use std::collections::BTreeMap;
22

33
use serde::{Serialize, Serializer};
44

5-
use super::{LabelName, LabelValue};
6-
7-
type LabelPair = (LabelName, LabelValue);
5+
use super::label_name_set::LabelNameSet;
6+
use super::{LabelName, LabelPair, LabelValue};
87

98
#[derive(Debug, Clone, Eq, PartialEq, Default, Ord, PartialOrd)]
109
pub struct LabelSet {
@@ -58,17 +57,6 @@ impl From<LabelPair> for LabelSet {
5857
}
5958
}
6059

61-
#[derive(Debug, Clone, Eq, PartialEq, Default, Serialize, Ord, PartialOrd)]
62-
pub struct LabelNameSet {
63-
values: Vec<LabelName>,
64-
}
65-
66-
impl From<Vec<LabelName>> for LabelNameSet {
67-
fn from(values: Vec<LabelName>) -> Self {
68-
Self { values }
69-
}
70-
}
71-
7260
#[derive(Debug, Clone, Eq, PartialEq, Default, Serialize)]
7361
struct SerializedLabel {
7462
name: LabelName,

packages/primitives/src/metrics/mod.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
pub mod label_name_set;
12
pub mod label_set;
23
pub mod labeled_metric;
34
pub mod labeled_metric_collection;
@@ -23,6 +24,8 @@ pub enum MetricKind {
2324
Gauge,
2425
}
2526

27+
type LabelPair = (LabelName, LabelValue);
28+
2629
#[derive(Debug, Clone, Eq, PartialEq, Default, Serialize, Hash, Ord, PartialOrd)]
2730
pub struct LabelName(String);
2831

0 commit comments

Comments
 (0)