Skip to content

Commit

Permalink
Merge pull request #4 from sebastienrousseau/feat/rssgen
Browse files Browse the repository at this point in the history
v0.0.3
  • Loading branch information
sebastienrousseau authored Oct 15, 2024
2 parents 4a7e57d + 712a086 commit 0ac0ca1
Show file tree
Hide file tree
Showing 13 changed files with 2,054 additions and 1,158 deletions.
8 changes: 7 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
[package]
# General project metadata
name = "rss-gen" # The name of the library
version = "0.0.2" # Initial version of the crate
version = "0.0.3" # Initial version of the crate
authors = ["RSS Generator Contributors"] # Library contributors
edition = "2021" # Rust edition being used
rust-version = "1.56.0" # Minimum supported Rust version
Expand Down Expand Up @@ -76,6 +76,12 @@ lazy_static = "1.5"
name = "rss_gen" # Internal name of the library
path = "src/lib.rs" # Path to the library entry point

# -----------------------------------------------------------------------------
# Features
# -----------------------------------------------------------------------------
[features]
async = []

# -----------------------------------------------------------------------------
# Benchmarking
# -----------------------------------------------------------------------------
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ Add this to your `Cargo.toml`:

```toml
[dependencies]
rss-gen = "0.0.2"
rss-gen = "0.0.3"
```

## Usage
Expand Down Expand Up @@ -84,7 +84,7 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
</rss>
"#;

match parse_rss(rss_content) {
match parse_rss(rss_content, None) {
Ok(parsed_data) => println!("Parsed RSS data: {:?}", parsed_data),
Err(e) => eprintln!("Error parsing RSS feed: {}", e),
}
Expand Down
6 changes: 3 additions & 3 deletions benches/criterion.rs
Original file line number Diff line number Diff line change
Expand Up @@ -68,13 +68,13 @@ fn benchmark_parse_rss(c: &mut Criterion) {
.warm_up_time(Duration::from_secs(3))
.measurement_time(Duration::from_secs(8));
group.bench_function("Small", |b| {
b.iter(|| parse_rss(black_box(&*SMALL_XML)))
b.iter(|| parse_rss(black_box(&*SMALL_XML), None))
});
group.bench_function("Medium", |b| {
b.iter(|| parse_rss(black_box(&*MEDIUM_XML)))
b.iter(|| parse_rss(black_box(&*MEDIUM_XML), None))
});
group.bench_function("Large", |b| {
b.iter(|| parse_rss(black_box(&*LARGE_XML)))
b.iter(|| parse_rss(black_box(&*LARGE_XML), None))
});
group.finish();
}
Expand Down
7 changes: 3 additions & 4 deletions examples/example_lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -82,10 +82,9 @@ fn parse_rss_example() -> Result<(), Box<dyn Error>> {
"#;

// Parse the RSS content
let rss_data = parse_rss(rss_content).map_err(|e| {
Box::new(ExampleError {
message: format!("Failed to parse RSS feed: {}", e),
}) as Box<dyn Error>
let rss_data = parse_rss(rss_content, None).map_err(|e| {
eprintln!("Error parsing RSS: {}", e);
e
})?;

println!(" ✅ Parsed RSS feed: {:#?}", rss_data); // Pretty-print the parsed data
Expand Down
14 changes: 7 additions & 7 deletions examples/example_parser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ fn parse_rss_example() -> Result<(), Box<dyn Error>> {
"#;

// Parse the RSS content
let parsed_data = parse_rss(xml_content).map_err(|e| {
let parsed_data = parse_rss(xml_content, None).map_err(|e| {
Box::new(ExampleError {
message: format!("Failed to parse RSS feed: {}", e),
}) as Box<dyn Error>
Expand Down Expand Up @@ -164,7 +164,7 @@ fn parse_rss_0_90_example() -> Result<(), Box<dyn Error>> {
</rdf:RDF>
"#;

let parsed_data = parse_rss(rss_0_90_content)?;
let parsed_data = parse_rss(rss_0_90_content, None)?;
println!("Parsed RSS 0.90 feed:");
println!("Title: {}", parsed_data.title);
println!("Link: {}", parsed_data.link);
Expand Down Expand Up @@ -194,7 +194,7 @@ fn parse_rss_0_91_example() -> Result<(), Box<dyn Error>> {
</rss>
"#;

let parsed_data = parse_rss(rss_0_91_content)?;
let parsed_data = parse_rss(rss_0_91_content, None)?;
println!("Parsed RSS 0.91 feed:");
println!("Title: {}", parsed_data.title);
println!("Link: {}", parsed_data.link);
Expand Down Expand Up @@ -230,7 +230,7 @@ fn parse_rss_0_92_example() -> Result<(), Box<dyn Error>> {
</rss>
"#;

let parsed_data = parse_rss(rss_0_92_content)?;
let parsed_data = parse_rss(rss_0_92_content, None)?;
println!("Parsed RSS 0.92 feed:");
println!("Title: {}", parsed_data.title);
println!("Link: {}", parsed_data.link);
Expand Down Expand Up @@ -274,7 +274,7 @@ fn parse_rss_1_0_example() -> Result<(), Box<dyn Error>> {
</rdf:RDF>
"#;

let parsed_data = parse_rss(rss_1_0_content)?;
let parsed_data = parse_rss(rss_1_0_content, None)?;
println!("Parsed RSS 1.0 feed:");
println!("Title: {}", parsed_data.title);
println!("Link: {}", parsed_data.link);
Expand All @@ -298,7 +298,7 @@ fn parse_rss_2_0_example() -> Result<(), Box<dyn Error>> {
<title>Normalizing XML, Part 2</title>
<link>http://www.xml.com/pub/a/2002/12/04/normalizing.html</link>
<description>In this second and final look at applying relational normalization
techniques to W3C XML Schema data modeling, Will Provost discusses when not to
techniques to W3C XML Schema data modelling, Will Provost discusses when not to
normalize, the scope of uniqueness and the fourth and fifth normal forms.</description>
<dc:creator>Will Provost</dc:creator>
<dc:date>2002-12-04</dc:date>
Expand All @@ -307,7 +307,7 @@ fn parse_rss_2_0_example() -> Result<(), Box<dyn Error>> {
</rss>
"#;

let parsed_data = parse_rss(rss_2_0_content)?;
let parsed_data = parse_rss(rss_2_0_content, None)?;
println!("Parsed RSS 2.0 feed:");
println!("Title: {}", parsed_data.title);
println!("Link: {}", parsed_data.link);
Expand Down
2 changes: 1 addition & 1 deletion examples/example_validator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ fn validate_rss_feed_example() -> Result<(), Box<dyn Error>> {
.link("https://myrustblog.com")
.description("A blog about Rust programming and tutorials.")
.atom_link("https://myrustblog.com/rss.xml") // Adding atom:link
.generator("RSS Gen v0.0.2"); // Adding generator
.generator("RSS Gen v0.0.3"); // Adding generator

// Adding at least one item to the feed
let item = RssItem::new()
Expand Down
Loading

0 comments on commit 0ac0ca1

Please sign in to comment.