From 671b3173c8ec77522fbc21a6916ebe81922edf81 Mon Sep 17 00:00:00 2001 From: Steven Roose Date: Tue, 3 Dec 2019 22:44:42 +0000 Subject: [PATCH] Make internals for CommandString private The From traits and AsRef and Display implementations let you do all you want. --- src/network/message.rs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/network/message.rs b/src/network/message.rs index cb4674be..fc421476 100644 --- a/src/network/message.rs +++ b/src/network/message.rs @@ -35,7 +35,7 @@ use consensus::encode::MAX_VEC_SIZE; /// Serializer for command string #[derive(PartialEq, Eq, Clone, Debug)] -pub struct CommandString(pub Cow<'static, str>); +pub struct CommandString(Cow<'static, str>); impl fmt::Display for CommandString { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { @@ -55,6 +55,12 @@ impl From for CommandString { } } +impl AsRef for CommandString { + fn as_ref(&self) -> &str { + self.0.as_ref() + } +} + impl Encodable for CommandString { #[inline] fn consensus_encode(