Skip to content

Commit 1012a5b

Browse files
committed
Change Link to use the Atom type instead
The code duplication didn't seem to be worth it
1 parent a5e112a commit 1012a5b

File tree

4 files changed

+13
-26
lines changed

4 files changed

+13
-26
lines changed

src/entry.rs

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
1-
extern crate atom_syndication;
2-
extern crate rss;
3-
extern crate chrono;
1+
use atom_syndication;
2+
use rss;
43

54
use chrono::{DateTime, UTC};
65
use category::Category;
7-
use link::Link;
6+
use atom_syndication::Link;
87

98
enum EntryData {
109
Atom(atom_syndication::Entry),
@@ -59,7 +58,7 @@ impl From<atom_syndication::Entry> for Entry {
5958
content: entry.content,
6059
links: entry.links
6160
.into_iter()
62-
.map(|link| Link { href: link.href })
61+
.map(|link| link.into())
6362
.collect::<Vec<_>>(),
6463
// TODO: Implement the Category type for converting this
6564
categories: vec![],

src/feed.rs

Lines changed: 7 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
1-
extern crate atom_syndication;
2-
extern crate rss;
3-
extern crate chrono;
1+
use atom_syndication;
2+
use rss;
43

54
use std::str::FromStr;
65
use chrono::{DateTime, UTC};
6+
use atom_syndication::{Link, Person};
77

88
use category::Category;
9-
use link::Link;
109
use entry::Entry;
1110

1211
enum FeedData {
@@ -45,12 +44,11 @@ pub struct Feed {
4544
pub links: Vec<Link>,
4645
// `categories` in both Atom and RSS
4746
pub categories: Vec<Category>,
48-
// TODO: Define our own Person type for API stability reasons
4947
// TODO: Should the `web_master` be in `contributors`, `authors`, or at all?
5048
// `authors` in Atom, `managing_editor` in RSS (produces 1 item Vec)
51-
pub authors: Vec<atom_syndication::Person>,
49+
pub authors: Vec<Person>,
5250
// `contributors` in Atom, `web_master` in RSS (produces a 1 item Vec)
53-
pub contributors: Vec<atom_syndication::Person>,
51+
pub contributors: Vec<Person>,
5452
// `entries` in Atom, and `items` in RSS
5553
// TODO: Add more fields that are necessary for RSS
5654
// TODO: Fancy translation, e.g. Atom <link rel="via"> = RSS `source`
@@ -71,11 +69,7 @@ impl From<atom_syndication::Feed> for Feed {
7169
icon: feed.icon,
7270
image: feed.logo,
7371
// NOTE: We throw away the generator field
74-
// TODO: Add more fields to the link type
75-
links: feed.links
76-
.into_iter()
77-
.map(|link| Link { href: link.href })
78-
.collect::<Vec<_>>(),
72+
links: feed.links,
7973
// TODO: Handle this once the Category type is defined
8074
categories: vec![],
8175
authors: feed.authors,
@@ -106,10 +100,7 @@ impl From<Feed> for atom_syndication::Feed {
106100
icon: feed.icon,
107101
logo: feed.image,
108102
generator: None,
109-
links: feed.links
110-
.into_iter()
111-
.map(|link| atom_syndication::Link { href: link.href, ..Default::default() })
112-
.collect::<Vec<_>>(),
103+
links: feed.links,
113104
// TODO: Convert from our Category type instead of throwing them away
114105
categories: vec![],
115106
authors: feed.authors,

src/lib.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,13 @@ extern crate rss;
33
extern crate chrono;
44

55
mod category;
6-
mod link;
76
mod person;
87
mod entry;
98
mod feed;
109

10+
pub use ::atom_syndication::Link;
11+
1112
pub use ::category::Category;
12-
pub use ::link::Link;
1313
pub use ::person::Person;
1414
pub use ::entry::Entry;
1515
pub use ::feed::Feed;

src/link.rs

Lines changed: 0 additions & 3 deletions
This file was deleted.

0 commit comments

Comments
 (0)