aboutsummaryrefslogtreecommitdiff
path: root/src/tw
diff options
context:
space:
mode:
Diffstat (limited to 'src/tw')
-rw-r--r--src/tw/mod.rs20
1 files changed, 20 insertions, 0 deletions
diff --git a/src/tw/mod.rs b/src/tw/mod.rs
index e2b8b03..b5ad72b 100644
--- a/src/tw/mod.rs
+++ b/src/tw/mod.rs
@@ -1,4 +1,5 @@
use std::path::Path;
+use std::fmt;
use std::str::FromStr;
use std::fs::File;
use std::io::{BufRead, BufReader, Read};
@@ -167,6 +168,25 @@ pub enum TweetId {
Twitter(String) // twitter::number
}
+impl fmt::Display for TweetId {
+ fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
+ match self {
+ &TweetId::Today(ref id) => {
+ write!(f, "{}", id)
+ },
+ &TweetId::Dated(ref date, ref id) => {
+ write!(f, "{}:{}", date, id)
+ },
+ &TweetId::Bare(ref id) => {
+ write!(f, ":{}", id)
+ },
+ &TweetId::Twitter(ref id) => {
+ write!(f, "twitter:{}", id)
+ }
+ }
+ }
+}
+
#[cfg(test)]
mod tests {
use super::*;