Rename parse functions to better indicate difference between gemfeed and atom

This commit is contained in:
projectmoon 2024-03-21 17:28:02 +01:00
parent dbddde049e
commit 4f0bb705fb
1 changed files with 6 additions and 6 deletions

View File

@ -29,7 +29,7 @@ fn is_gemfeed_post_link(node: &GemtextNode) -> bool {
} }
} }
fn parse_gemfeed_gemtext(base_url: &Url, gemfeed: &GemtextAst) -> Result<Vec<GemfeedEntry>> { fn parse_gemfeed(base_url: &Url, gemfeed: &GemtextAst) -> Result<Vec<GemfeedEntry>> {
gemfeed gemfeed
.inner() .inner()
.into_iter() .into_iter()
@ -38,7 +38,7 @@ fn parse_gemfeed_gemtext(base_url: &Url, gemfeed: &GemtextAst) -> Result<Vec<Gem
.collect() .collect()
} }
fn parse_gemfeed_atom( fn parse_atom(
feed: &AtomFeed, feed: &AtomFeed,
settings: &GemfeedParserSettings, settings: &GemfeedParserSettings,
) -> Result<Vec<GemfeedEntry>> { ) -> Result<Vec<GemfeedEntry>> {
@ -145,7 +145,7 @@ impl Gemfeed {
) -> Result<Gemfeed> { ) -> Result<Gemfeed> {
if let Some(content) = resp.content() { if let Some(content) = resp.content() {
let feed = content.parse::<AtomFeed>()?; let feed = content.parse::<AtomFeed>()?;
let entries = parse_gemfeed_atom(&feed, settings)?; let entries = parse_atom(&feed, settings)?;
let title = feed.title(); let title = feed.title();
Ok(Self::new(url, title, entries)) Ok(Self::new(url, title, entries))
} else { } else {
@ -173,7 +173,7 @@ impl Gemfeed {
}); });
if let Some(title) = feed_title { if let Some(title) = feed_title {
let entries = parse_gemfeed_gemtext(url, feed)?; let entries = parse_gemfeed(url, feed)?;
Ok(Self::new(url, title, entries)) Ok(Self::new(url, title, entries))
} else { } else {
Err(anyhow!("Not a valid Gemfeed: missing title")) Err(anyhow!("Not a valid Gemfeed: missing title"))
@ -452,7 +452,7 @@ mod gemfeed_tests {
let base_url = Url::parse("gemini://example.com/posts")?; let base_url = Url::parse("gemini://example.com/posts")?;
let ast = GemtextAst::from_string(gemfeed); let ast = GemtextAst::from_string(gemfeed);
let results = parse_gemfeed_gemtext(&base_url, &ast)?; let results = parse_gemfeed(&base_url, &ast)?;
assert_eq!(results.len(), 2); assert_eq!(results.len(), 2);
Ok(()) Ok(())
} }
@ -476,7 +476,7 @@ mod gemfeed_tests {
let base_url = Url::parse("gemini://example.com/posts")?; let base_url = Url::parse("gemini://example.com/posts")?;
let ast = GemtextAst::from_string(gemfeed); let ast = GemtextAst::from_string(gemfeed);
let results = parse_gemfeed_gemtext(&base_url, &ast)?; let results = parse_gemfeed(&base_url, &ast)?;
assert_eq!(results.len(), 2); assert_eq!(results.len(), 2);
Ok(()) Ok(())
} }