From: Simon Tatham Date: Mon, 1 Jan 2024 09:21:22 +0000 (+0000) Subject: Rename FeedFile and friends. X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~ian/git?a=commitdiff_plain;h=5a32f8dd6f32f64987a3effd3361a8200d0a5801;p=mastodonochrome.git Rename FeedFile and friends. The scrolling-file system is about to be reused for things that aren't feeds, so it will be confusing to have the structs all called FeedThing. --- diff --git a/src/file.rs b/src/file.rs index 28409e8..f1541a3 100644 --- a/src/file.rs +++ b/src/file.rs @@ -24,7 +24,7 @@ impl FilePosition { } } -trait FeedType { +trait FileType { type Item: TextFragment + Sized; fn get_from_client(id: &str, client: &mut Client) -> @@ -32,7 +32,7 @@ trait FeedType { } struct StatusFeedType {} -impl FeedType for StatusFeedType { +impl FileType for StatusFeedType { type Item = StatusDisplay; fn get_from_client(id: &str, client: &mut Client) -> @@ -44,7 +44,7 @@ impl FeedType for StatusFeedType { } struct NotificationStatusFeedType {} -impl FeedType for NotificationStatusFeedType { +impl FileType for NotificationStatusFeedType { type Item = StatusDisplay; fn get_from_client(id: &str, client: &mut Client) -> @@ -58,7 +58,7 @@ impl FeedType for NotificationStatusFeedType { } struct EgoNotificationFeedType {} -impl FeedType for EgoNotificationFeedType { +impl FileType for EgoNotificationFeedType { type Item = NotificationLog; fn get_from_client(id: &str, client: &mut Client) -> @@ -69,7 +69,7 @@ impl FeedType for EgoNotificationFeedType { } } -struct FeedFileContents { +struct FileContents { id: FeedId, header: FileHeader, extender: Option, @@ -77,7 +77,7 @@ struct FeedFileContents { items: Vec, } -impl FeedFileContents { +impl FileContents { fn update_items(&mut self, client: &mut Client) { // FIXME: if the feed has been extended rather than created, // we should be able to make less effort than this @@ -127,20 +127,20 @@ impl FeedFileContents { } } -struct FeedFile { - contents: FeedFileContents, +struct File { + contents: FileContents, rendered: HashMap>, pos: FilePosition, last_size: Option<(usize, usize)>, } -impl FeedFile { +impl File { fn new(client: &mut Client, id: FeedId, desc: ColouredString) -> Result { client.fetch_feed(&id, FeedExtend::Initial)?; - let mut contents = FeedFileContents { + let mut contents = FileContents { id: id, header: FileHeader::new(desc), extender: Some(ExtendableIndicator::new()), @@ -153,7 +153,7 @@ impl FeedFile { // FIXME: once we have an LDB, that's where initial pos comes from let initial_pos = FilePosition::Coarse(contents.last_index() as isize); - let ff = FeedFile { + let ff = File { contents: contents, rendered: HashMap::new(), pos: initial_pos, @@ -350,7 +350,7 @@ impl FeedFile { } } -impl ActivityState for FeedFile { +impl ActivityState for File { fn resize(&mut self, w: usize, h: usize) { if self.last_size != Some((w, h)) { self.last_size = Some((w, h)); @@ -511,7 +511,7 @@ impl ActivityState for FeedFile { pub fn home_timeline(client: &mut Client) -> Result, ClientError> { - let file = FeedFile::::new( + let file = File::::new( client, FeedId::Home, ColouredString::general( "Home timeline ", "HHHHHHHHHHHHHHHHHKH"))?; @@ -521,7 +521,7 @@ pub fn home_timeline(client: &mut Client) -> pub fn local_timeline(client: &mut Client) -> Result, ClientError> { - let file = FeedFile::::new( + let file = File::::new( client, FeedId::Local, ColouredString::general( "Local public timeline ", "HHHHHHHHHHHHHHHHHHHHHHHHHKH"))?; @@ -531,7 +531,7 @@ pub fn local_timeline(client: &mut Client) -> pub fn public_timeline(client: &mut Client) -> Result, ClientError> { - let file = FeedFile::::new( + let file = File::::new( client, FeedId::Public, ColouredString::general( "Public timeline

", "HHHHHHHHHHHHHHHHHHHKH"))?; @@ -541,7 +541,7 @@ pub fn public_timeline(client: &mut Client) -> pub fn mentions(client: &mut Client) -> Result, ClientError> { - let file = FeedFile::::new( + let file = File::::new( client, FeedId::Mentions, ColouredString::general( "Mentions [ESC][R]", "HHHHHHHHHHHHKKKHHKH"))?; @@ -551,7 +551,7 @@ pub fn mentions(client: &mut Client) -> pub fn ego_log(client: &mut Client) -> Result, ClientError> { - let file = FeedFile::::new( + let file = File::::new( client, FeedId::Ego, ColouredString::general( "Ego Log [ESC][L][L][E]", "HHHHHHHHHHHKKKHHKHHKHHKH"))?;