Make internals for CommandString private

The From traits and AsRef and Display implementations
let you do all you want.
This commit is contained in:
Steven Roose 2019-12-03 22:44:42 +00:00
parent 83f55b7f1d
commit 671b3173c8
No known key found for this signature in database
GPG Key ID: 2F2A88D7F8D68E87
1 changed files with 7 additions and 1 deletions

View File

@ -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<String> for CommandString {
}
}
impl AsRef<str> for CommandString {
fn as_ref(&self) -> &str {
self.0.as_ref()
}
}
impl Encodable for CommandString {
#[inline]
fn consensus_encode<S: io::Write>(