@@ -70,8 +70,21 @@ const HTML: &str = r#"<html>
7070</body> 
7171</html>" #  ;
7272
73+ #[tokio:: main]
74+ async  fn  main () ->  css_inline :: Result <()> {
75+     let  inlined  =  css_inline :: inline (HTML ). await ? ;
76+     //  Do something with inlined HTML, e.g. send an email
77+     Ok (())
78+ }
79+ ``` 
80+ 
81+ There is also a "blocking" API for inlining:
82+ 
83+ ``` rust 
84+ const  HTML :  & str  =  " ..." 
85+ 
7386fn  main () ->  css_inline :: Result <()> {
74-     let  inlined  =  css_inline :: inline (HTML )? ;
87+     let  inlined  =  css_inline :: blocking :: inline (HTML )? ;
7588    //  Do something with inlined HTML, e.g. send an email
7689    Ok (())
7790}
@@ -84,11 +97,12 @@ fn main() -> css_inline::Result<()> {
8497``` rust 
8598const  HTML :  & str  =  " ..." 
8699
87- fn  main () ->  css_inline :: Result <()> {
100+ #[tokio:: main]
101+ async  fn  main () ->  css_inline :: Result <()> {
88102    let  inliner  =  css_inline :: CSSInliner :: options ()
89103        . load_remote_stylesheets (false )
90104        . build ();
91-     let  inlined  =  inliner . inline (HTML )? ;
105+     let  inlined  =  inliner . inline (HTML ). await ? ;
92106    //  Do something with inlined HTML, e.g. send an email
93107    Ok (())
94108}
@@ -131,12 +145,28 @@ If you'd like to load stylesheets from your filesystem, use the `file://` scheme
131145``` rust 
132146const  HTML :  & str  =  " ..." 
133147
134- fn  main () ->  css_inline :: Result <()> {
148+ #[tokio:: main]
149+ async  fn  main () ->  css_inline :: Result <()> {
135150    let  base_url  =  css_inline :: Url :: parse (" file://styles/email/" . expect (" Invalid URL" 
136151    let  inliner  =  css_inline :: CSSInliner :: options ()
137152        . base_url (Some (base_url ))
138153        . build ();
139-     let  inlined  =  inliner . inline (HTML );
154+     let  inlined  =  inliner . inline (HTML ). await ? ;
155+     //  Do something with inlined HTML, e.g. send an email
156+     Ok (())
157+ }
158+ ``` 
159+ 
160+ The blocking version is available as well:
161+ 
162+ ``` rust 
163+ const  HTML :  & str  =  " ..." 
164+ 
165+ fn  main () ->  css_inline :: Result <()> {
166+     let  inliner  =  css_inline :: blocking :: CSSInliner :: options ()
167+         . load_remote_stylesheets (false )
168+         . build ();
169+     let  inlined  =  inliner . inline (HTML )? ;
140170    //  Do something with inlined HTML, e.g. send an email
141171    Ok (())
142172}
@@ -149,7 +179,7 @@ For resolving remote stylesheets it is possible to implement a custom resolver:
149179pub  struct  CustomStylesheetResolver ;
150180
151181impl  css_inline :: StylesheetResolver  for  CustomStylesheetResolver  {
152-     fn  retrieve (& self , location :  & str ) ->  css_inline :: Result <String > {
182+     fn  retrieve_blocking (& self , location :  & str ) ->  css_inline :: Result <String > {
153183        Err (self . unsupported (" External stylesheets are not supported" 
154184    }
155185}
0 commit comments