diff options
Diffstat (limited to 'src/config/endpoint_config.rs')
-rw-r--r-- | src/config/endpoint_config.rs | 27 |
1 files changed, 23 insertions, 4 deletions
diff --git a/src/config/endpoint_config.rs b/src/config/endpoint_config.rs index 13db137..69405dc 100644 --- a/src/config/endpoint_config.rs +++ b/src/config/endpoint_config.rs @@ -11,13 +11,31 @@ use getset::{CopyGetters, Getters}; use serde::Deserialize; +#[derive(Debug, Clone, Deserialize, Eq, PartialEq, Ord, PartialOrd, Hash)] +#[serde(transparent)] +pub struct EndpointName(String); + +impl From<String> for EndpointName { + fn from(s: String) -> Self { + EndpointName(s) + } +} + +impl std::fmt::Display for EndpointName { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::result::Result<(), std::fmt::Error> { + self.0.fmt(f) + } +} + +impl AsRef<str> for EndpointName { + fn as_ref(&self) -> &str { + self.0.as_ref() + } +} + /// Configuration of a single endpoint #[derive(Clone, Debug, Getters, CopyGetters, Deserialize)] pub struct Endpoint { - /// A human-readable name of the endpoint - #[getset(get = "pub")] - name: String, - /// The URI where the endpoint is reachable #[getset(get = "pub")] uri: String, @@ -42,3 +60,4 @@ pub enum EndpointType { #[serde(rename = "http")] Http, } + |