diff --git a/src/common.rs b/src/common.rs index bbc09c9..d8be54c 100644 --- a/src/common.rs +++ b/src/common.rs @@ -1,5 +1,6 @@ //! Common data types included in EPP Requests and Responses +use std::ops::Deref; use std::{borrow::Cow, fmt::Display, net::IpAddr}; use serde::ser::SerializeSeq; @@ -14,6 +15,20 @@ pub(crate) const EPP_XMLNS: &str = "urn:ietf:params:xml:ns:epp-1.0"; #[derive(Default, Serialize, Deserialize, Debug, PartialEq, Clone)] pub struct StringValue<'a>(Cow<'a, str>); +impl Deref for StringValue<'_> { + type Target = str; + + fn deref(&self) -> &Self::Target { + self.0.as_ref() + } +} + +impl<'a> AsRef for StringValue<'a> { + fn as_ref(&self) -> &str { + self.0.as_ref() + } +} + impl Display for StringValue<'_> { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { write!(f, "{}", self.0)