#[derive(Clone, Debug, PartialEq, Eq)] pub struct Commit { sha: Sha, message: Message, } impl Commit { pub fn new(sha: &str, message: &str) -> Self { Self { sha: Sha::new(sha.to_string()), message: Message::new(message.to_string()), } } pub const fn sha(&self) -> &Sha { &self.sha } pub const fn message(&self) -> &Message { &self.message } } impl std::fmt::Display for Commit { fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { write!(f, "{}", self.sha) } } #[derive(Clone, Debug, PartialEq, Eq)] pub struct Sha(String); impl Sha { pub const fn new(value: String) -> Self { Self(value) } } impl std::fmt::Display for Sha { fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { write!(f, "{}", self.0) } } #[derive(Clone, Debug, PartialEq, Eq)] pub struct Message(String); impl Message { pub const fn new(value: String) -> Self { Self(value) } } impl std::fmt::Display for Message { fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { write!(f, "{}", self.0) } }