data: consolidate the YAML embed convention into an embed_data! macro
This commit is contained in:
+5
-7
@@ -1,3 +1,4 @@
|
||||
use crate::data::embed_data;
|
||||
use chrono::NaiveDate;
|
||||
use lazy_static::lazy_static;
|
||||
use serde::Deserialize;
|
||||
@@ -43,14 +44,11 @@ struct Data {
|
||||
dist: std::collections::HashMap<String, DistData>,
|
||||
}
|
||||
|
||||
const DATA_YAML: &str = include_str!("../data/distro_info.yml");
|
||||
lazy_static! {
|
||||
// The YAML is include_str!'d at compile time and statically valid; if it
|
||||
// ever failed to parse it would be a build-time bug that cannot be
|
||||
// recovered from at runtime, so panicking here is acceptable.
|
||||
static ref DATA: Data = serde_yaml::from_str(DATA_YAML)
|
||||
.expect("built-in distro_info.yml data is statically valid and must parse");
|
||||
embed_data! {
|
||||
static ref DATA: Data = "../data/distro_info.yml"
|
||||
}
|
||||
|
||||
lazy_static! {
|
||||
// Shared HTTP client used for all outgoing plain requests: timeouts keep
|
||||
// a hanging remote (connect or transfer) from stalling pkh indefinitely.
|
||||
// The short pool idle timeout and TCP keepalive avoid reusing keep-alive
|
||||
|
||||
Reference in New Issue
Block a user