}
}
-trait FeedType {
+trait FileType {
type Item: TextFragment + Sized;
fn get_from_client(id: &str, client: &mut Client) ->
}
struct StatusFeedType {}
-impl FeedType for StatusFeedType {
+impl FileType for StatusFeedType {
type Item = StatusDisplay;
fn get_from_client(id: &str, client: &mut Client) ->
}
struct NotificationStatusFeedType {}
-impl FeedType for NotificationStatusFeedType {
+impl FileType for NotificationStatusFeedType {
type Item = StatusDisplay;
fn get_from_client(id: &str, client: &mut Client) ->
}
struct EgoNotificationFeedType {}
-impl FeedType for EgoNotificationFeedType {
+impl FileType for EgoNotificationFeedType {
type Item = NotificationLog;
fn get_from_client(id: &str, client: &mut Client) ->
}
}
-struct FeedFileContents<Type: FeedType> {
+struct FileContents<Type: FileType> {
id: FeedId,
header: FileHeader,
extender: Option<ExtendableIndicator>,
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
}
}
-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()),
// 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,
}
}
-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));
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"))?;
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"))?;
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"))?;
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"))?;
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"))?;