rust-syndication / rss

Library for serializing the RSS web content syndication format
https://crates.io/crates/rss
Apache License 2.0
419 stars 52 forks source link

Added setters to structs #52

Closed jameshurst closed 7 years ago

jameshurst commented 7 years ago

Revisiting #41, I've added setters to all the structs, replacing the shim I had put in earlier to create builders from existing structs.

Examples have been revised to be more succinct.

The builders are now automatically created using derive_builder crate which should help keep builder methods and struct properties consistent.

These changes bring the code more in line with the patterns that I used in the atom_syndication crate as well which should make understanding one library easier if you've already used the other.

Additionally I've also moved validation out to its own module and made it an optional dependency to try and keep the core crate focused on just reading and writing.

frewsxcv commented 7 years ago

How difficult would it be to separate the 'setters' changes and the 'validation' changes? If it's easy, is it cool to put them in separate (maybe subsequent) PRs?

jameshurst commented 7 years ago

Since all the validation methods were previously part of the builder structs I had to remove them when switching to the derived builders. So it probably wouldn't be all that simple to have split out those changes.

jameshurst commented 7 years ago

The derived builders have the option to not take Into<T> but the advantage of using Into<T> instead of T is you can pass T to a setter that would normally take an Option<T> or an &str to a setter that would take a String which makes the API a bit nicer to use.