diff options
author | Bryan Newbold <bnewbold@robocracy.org> | 2019-01-09 18:30:48 -0800 |
---|---|---|
committer | Bryan Newbold <bnewbold@robocracy.org> | 2019-01-09 18:30:48 -0800 |
commit | 7632129c594b9edbae8ee9ba5da6ae35d1af2429 (patch) | |
tree | db1c56b35aa4c81ec1c925d527b80caa30f9c06f /rust/src/identifiers.rs | |
parent | 8317f6cb38622e36dad6bd4ad34e3cf6dac3bdad (diff) | |
download | fatcat-7632129c594b9edbae8ee9ba5da6ae35d1af2429.tar.gz fatcat-7632129c594b9edbae8ee9ba5da6ae35d1af2429.zip |
refactor: FatCatId -> FatcatId
Diffstat (limited to 'rust/src/identifiers.rs')
-rw-r--r-- | rust/src/identifiers.rs | 29 |
1 files changed, 14 insertions, 15 deletions
diff --git a/rust/src/identifiers.rs b/rust/src/identifiers.rs index e107d16f..073464aa 100644 --- a/rust/src/identifiers.rs +++ b/rust/src/identifiers.rs @@ -3,51 +3,50 @@ use data_encoding::BASE32_NOPAD; use regex::Regex; use serde_json; use std::str::FromStr; +use std::{convert, fmt}; use uuid::Uuid; -use std::{fmt, convert}; - #[derive(Clone, Copy, PartialEq, Debug)] -pub struct FatCatId(Uuid); +pub struct FatcatId(Uuid); -impl fmt::Display for FatCatId { +impl fmt::Display for FatcatId { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { write!(f, "{}", uuid2fcid(&self.to_uuid())) } } -impl FromStr for FatCatId { +impl FromStr for FatcatId { type Err = Error; - fn from_str(s: &str) -> Result<FatCatId> { - fcid2uuid(s).map(FatCatId) + fn from_str(s: &str) -> Result<FatcatId> { + fcid2uuid(s).map(FatcatId) } } -impl convert::AsRef<Uuid> for FatCatId { +impl convert::AsRef<Uuid> for FatcatId { fn as_ref(&self) -> &Uuid { &self.0 } } -impl convert::Into<Uuid> for FatCatId { +impl convert::Into<Uuid> for FatcatId { fn into(self) -> Uuid { self.0 } } -impl convert::From<Uuid> for FatCatId { - fn from(u: Uuid) -> FatCatId { - FatCatId(u) +impl convert::From<Uuid> for FatcatId { + fn from(u: Uuid) -> FatcatId { + FatcatId(u) } } -impl FatCatId { +impl FatcatId { pub fn to_uuid(&self) -> Uuid { self.0 } // TODO: make it possible to just pass 'Uuid' in addition to '&Uuid' - pub fn from_uuid(u: &Uuid) -> FatCatId { - FatCatId(*u) + pub fn from_uuid(u: &Uuid) -> FatcatId { + FatcatId(*u) } } |