Use a struct with a trait rather than several arguments in self_contained_html #3

Closed
opened 2021-04-09 15:51:08 +02:00 by koalp · 0 comments
Owner

Currently, the self_contained_html takes two configuration arguments which are downloader, a function to download documents, and base_url, the base url for relative links.

pub fn self_contained_html<S: AsRef<str>>(
    html: S,
    downloader: &dyn Fn(Url) -> Option<String>,
    base_url: &Url,
) -> String {

It would maybe be better to require one config structure with a trait, as it would allow to reduce argument numbers as well as clarifying the function role.

It would also allow to provide a default downloader (¿rename to download ?) function, and write helpers function for different format (images, css) directly in the trait.

Currently, the self_contained_html takes two configuration arguments which are `downloader`, a function to download documents, and base_url, the base url for relative links. ```rust pub fn self_contained_html<S: AsRef<str>>( html: S, downloader: &dyn Fn(Url) -> Option<String>, base_url: &Url, ) -> String { ``` It would maybe be better to require one config structure with a trait, as it would allow to reduce argument numbers as well as clarifying the function role. It would also allow to provide a default `downloader` (¿rename to `download` ?) function, and write helpers function for different format (images, css) directly in the trait.
koalp added the
status
review_needed
type
refactor
labels 2021-04-09 15:51:08 +02:00
koalp added
status
accepted
and removed
status
review_needed
labels 2021-04-23 22:30:15 +02:00
koalp added this to the 2021-04-05 - 2021-04-25 : sprint project 2021-04-23 22:34:28 +02:00
koalp added this to the v0.1.0 - multiple newspaper, html only, chatbot milestone 2021-04-23 22:39:22 +02:00
koalp closed this issue 2021-04-24 03:51:27 +02:00
Sign in to join this conversation.
No description provided.