1use std::{fmt::Display, str::FromStr, string::ParseError};
2
3#[derive(Clone, PartialEq, Eq, PartialOrd, Ord)]
10pub struct HellmanOutput(String);
11
12impl Default for HellmanOutput {
13 fn default() -> Self {
14 Self("OUTPUT".to_string())
15 }
16}
17
18impl FromStr for HellmanOutput {
19 type Err = ParseError;
20
21 fn from_str(s: &str) -> Result<Self, Self::Err> {
22 Ok(Self::default().push_str(s))
23 }
24}
25
26impl Display for HellmanOutput {
27 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
28 write!(f, "{}", self.0)
29 }
30}
31
32impl HellmanOutput {
33 pub fn push_numeric(&self, num: isize) -> Self {
35 let num_str = &format!(" {} ", num);
36 Self(self.0.clone() + num_str)
37 }
38
39 pub fn push_str(&self, s: &str) -> Self {
41 let new_addition = &format!(" :{}: ", s);
42 Self(self.0.clone() + new_addition)
43 }
44}