summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthias Beyer <mail@beyermatthias.de>2021-01-03 10:36:21 +0100
committerMatthias Beyer <mail@beyermatthias.de>2021-01-03 10:37:32 +0100
commit709eba5cfa7adba9af3611220fc9c4c28fcded1e (patch)
treed21a5f7d1baf65e2f71adbece3fbc13269ed74d4
parente503e291c9865eca6337fedd850e6bbeeb0934f7 (diff)
Make {Search, Query}Response not have public fieldsupdate
Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
-rw-r--r--src/api.rs17
-rw-r--r--src/main.rs8
2 files changed, 19 insertions, 6 deletions
diff --git a/src/api.rs b/src/api.rs
index 1f9a904..e09b62e 100644
--- a/src/api.rs
+++ b/src/api.rs
@@ -69,8 +69,21 @@ pub struct Search {
}
#[derive(Serialize, Deserialize, Debug, PartialEq, Clone)]
-pub struct SearchResponse(pub Vec<String>);
+pub struct SearchResponse(Vec<String>);
+
+impl From<Vec<String>> for SearchResponse {
+ fn from(v: Vec<String>) -> Self {
+ SearchResponse(v)
+ }
+}
#[derive(Serialize, Deserialize, Debug, PartialEq, Clone)]
-pub struct QueryResponse(pub Vec<TargetData>);
+pub struct QueryResponse(Vec<TargetData>);
+
+
+impl From<Vec<TargetData>> for QueryResponse {
+ fn from(v: Vec<TargetData>) -> Self {
+ QueryResponse(v)
+ }
+}
diff --git a/src/main.rs b/src/main.rs
index b97a595..dd48132 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -57,7 +57,7 @@ fn search(data : Json<Search>, config: State<Config>) -> Json<SearchResponse> {
debug!("handling search request: {:?}", data.0);
Json(
- SearchResponse(
+ SearchResponse::from(
(*config.all_aliases()).clone()
)
)
@@ -77,13 +77,13 @@ fn query(data: Json<Query>, config: State<Config>) -> Result<Json<QueryResponse>
Ok(
Json(
- QueryResponse{
- 0 : hash_map_iter(
+ QueryResponse::from({
+ hash_map_iter(
hash_map_targets(&config, data.0.targets)?,
data.0.range.from.timestamp(),
data.0.range.to.timestamp()
)?
- }
+ })
)
)
}