chiark / gitweb /
Rename FeedFile and friends.
authorSimon Tatham <anakin@pobox.com>
Mon, 1 Jan 2024 09:21:22 +0000 (09:21 +0000)
committerSimon Tatham <anakin@pobox.com>
Mon, 1 Jan 2024 10:10:14 +0000 (10:10 +0000)
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.

src/file.rs

index 28409e8b876d878fcd3fc31db939b8a3eff42cdb..f1541a30052fdd31d84d7ff006572a0acd9b96c0 100644 (file)
@@ -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<Type: FeedType> {
+struct FileContents<Type: FileType> {
     id: FeedId,
     header: FileHeader,
     extender: Option<ExtendableIndicator>,
@@ -77,7 +77,7 @@ struct FeedFileContents<Type: FeedType> {
     items: Vec<Type::Item>,
 }
 
-impl<Type: FeedType> FeedFileContents<Type> {
+impl<Type: FileType> FileContents<Type> {
     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<Type: FeedType> FeedFileContents<Type> {
     }
 }
 
-struct FeedFile<Type: FeedType> {
-    contents: FeedFileContents<Type>,
+struct File<Type: FileType> {
+    contents: FileContents<Type>,
     rendered: HashMap<isize, Vec<ColouredString>>,
     pos: FilePosition,
     last_size: Option<(usize, usize)>,
 }
 
-impl<Type: FeedType> FeedFile<Type> {
+impl<Type: FileType> File<Type> {
     fn new(client: &mut Client, id: FeedId, desc: ColouredString) ->
         Result<Self, ClientError>
     {
         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<Type: FeedType> FeedFile<Type> {
         // 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<Type: FeedType> FeedFile<Type> {
     }
 }
 
-impl<Type: FeedType> ActivityState for FeedFile<Type> {
+impl<Type: FileType> ActivityState for File<Type> {
     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<Type: FeedType> ActivityState for FeedFile<Type> {
 pub fn home_timeline(client: &mut Client) ->
     Result<Box<dyn ActivityState>, ClientError>
 {
-    let file = FeedFile::<StatusFeedType>::new(
+    let file = File::<StatusFeedType>::new(
         client, FeedId::Home, ColouredString::general(
             "Home timeline   <H>",
             "HHHHHHHHHHHHHHHHHKH"))?;
@@ -521,7 +521,7 @@ pub fn home_timeline(client: &mut Client) ->
 pub fn local_timeline(client: &mut Client) ->
     Result<Box<dyn ActivityState>, ClientError>
 {
-    let file = FeedFile::<StatusFeedType>::new(
+    let file = File::<StatusFeedType>::new(
         client, FeedId::Local, ColouredString::general(
             "Local public timeline   <L>",
             "HHHHHHHHHHHHHHHHHHHHHHHHHKH"))?;
@@ -531,7 +531,7 @@ pub fn local_timeline(client: &mut Client) ->
 pub fn public_timeline(client: &mut Client) ->
     Result<Box<dyn ActivityState>, ClientError>
 {
-    let file = FeedFile::<StatusFeedType>::new(
+    let file = File::<StatusFeedType>::new(
         client, FeedId::Public, ColouredString::general(
             "Public timeline   <P>",
             "HHHHHHHHHHHHHHHHHHHKH"))?;
@@ -541,7 +541,7 @@ pub fn public_timeline(client: &mut Client) ->
 pub fn mentions(client: &mut Client) ->
     Result<Box<dyn ActivityState>, ClientError>
 {
-    let file = FeedFile::<NotificationStatusFeedType>::new(
+    let file = File::<NotificationStatusFeedType>::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<Box<dyn ActivityState>, ClientError>
 {
-    let file = FeedFile::<EgoNotificationFeedType>::new(
+    let file = File::<EgoNotificationFeedType>::new(
         client, FeedId::Ego, ColouredString::general(
             "Ego Log   [ESC][L][L][E]",
             "HHHHHHHHHHHKKKHHKHHKHHKH"))?;