otoxteam / web_ical

web_ical is an esay iCalendar Rust library. It’s goals are to read and write ics web files (Google Calendar, Airbnb Calendar and more) data in a developer-friendly way.
MIT License
15 stars 11 forks source link

Allow export to any Writer implementor #1

Closed editicalu closed 5 years ago

editicalu commented 5 years ago

For my application, I need to export ical calendars to the standard output.

I generalized your export to file method (export_ics). This approach does not block the program and writes all the data at once, making the program way faster and allow the export to basically anything. To show how much faster, I've added a benchmark:

   Compiling web_ical v0.1.2 (/home/editicalu/git/web_ical)
    Finished release [optimized] target(s) in 2.28s
     Running target/release/deps/web_ical-224d02a0345689f5

running 0 tests

test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out

     Running target/release/deps/web_ical-453f362bb19a05e9

running 0 tests

test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out

     Running target/release/deps/bench-f3183d2e6c58b869

running 2 tests
test export_ics    ... bench:      20,732 ns/iter (+/- 5,466)
test export_writer ... bench:     131,250 ns/iter (+/- 30,571)

Also, there were some formatting errors, which I formatted using cargo fmt.

otoxteam commented 5 years ago

Thank you very much for your input, an excellent job