✨ feat(message_list): create message summary struct
- introduce MessageSummary struct to encapsulate message id and subject - implement methods to set and retrieve subject, with default if missing
This commit is contained in:
committed by
Jeremiah Russell
parent
65f8bf7fc5
commit
a0b365a455
30
src/message_list/message_summary.rs
Normal file
30
src/message_list/message_summary.rs
Normal file
@@ -0,0 +1,30 @@
|
||||
#[derive(Debug)]
|
||||
pub(crate) struct MessageSummary {
|
||||
id: String,
|
||||
subject: Option<String>,
|
||||
}
|
||||
|
||||
impl MessageSummary {
|
||||
pub(crate) fn new(id: &str) -> Self {
|
||||
MessageSummary {
|
||||
id: id.to_string(),
|
||||
subject: None,
|
||||
}
|
||||
}
|
||||
|
||||
pub(crate) fn id(&self) -> &str {
|
||||
&self.id
|
||||
}
|
||||
|
||||
pub(crate) fn set_subject(&mut self, subject: &str) {
|
||||
self.subject = Some(subject.to_string())
|
||||
}
|
||||
|
||||
pub(crate) fn subject(&self) -> &str {
|
||||
if let Some(s) = &self.subject {
|
||||
s
|
||||
} else {
|
||||
"*** No Subject for Message ***"
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user