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