Module cache_buster::processor [−][src]
Module cache_buster::processor [−][src]
Module describing file processor that changes filenames to setup cache-busting
Run the following during build using build.rs
:
diff --git a/cache_buster/processor/struct.Buster.html b/cache_buster/processor/struct.Buster.html index 9e4b3ef..e8a9c4b 100644 --- a/cache_buster/processor/struct.Buster.html +++ b/cache_buster/processor/struct.Buster.html @@ -1,13 +1,13 @@Buster in cache_buster::processor - Rust Struct cache_buster::
processor:: [−][src]Buster pub struct Buster { /* fields omitted */ }Configuration for setting up cache-busting
-Implementations
impl Buster
[src]
pub fn process(&self) -> Result<(), Error>
[src]Struct cache_buster::
processor:: [−][src]Buster pub struct Buster<'a> { /* fields omitted */ }Configuration for setting up cache-busting
+Implementations
Trait Implementations
Trait Implementations
Auto Trait Implementations
impl RefUnwindSafe for Buster
impl Send for Buster
impl Sync for Buster
impl Unpin for Buster
impl UnwindSafe for Buster
Blanket Implementations
Auto Trait Implementations
impl<'a> RefUnwindSafe for Buster<'a>
impl<'a> Send for Buster<'a>
impl<'a> Sync for Buster<'a>
impl<'a> Unpin for Buster<'a>
impl<'a> UnwindSafe for Buster<'a>
Blanket Implementations
impl<T> BorrowMut<T> for T where
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T
[src]Mutably borrows from an owned value. Read more
impl<T> From<T> for T
[src]
pub fn from(t: T) -> T
[src]Performs the conversion.
diff --git a/cache_buster/processor/struct.BusterBuilder.html b/cache_buster/processor/struct.BusterBuilder.html index f3da38c..5e24d5e 100644 --- a/cache_buster/processor/struct.BusterBuilder.html +++ b/cache_buster/processor/struct.BusterBuilder.html @@ -1,20 +1,23 @@BusterBuilder in cache_buster::processor - Rust -Struct cache_buster::
processor:: [−][src]BusterBuilder pub struct BusterBuilder { /* fields omitted */ }Builder for
-Buster
.Implementations
impl BusterBuilder
[src]
pub fn source<VALUE: Into<String>>(&mut self, value: VALUE) -> &mut Self
[src]source directory
+Struct cache_buster::
processor:: [−][src]BusterBuilder pub struct BusterBuilder<'a> { /* fields omitted */ }Builder for
+Buster
.Implementations
impl<'a> BusterBuilder<'a>
[src]
pub fn source<VALUE: Into<String>>(&mut self, value: VALUE) -> &mut Self
[src]source directory
pub fn mime_types(&mut self, value: Vec<Mime>) -> &mut Self
[src]mime_types for hashing
pub fn result<VALUE: Into<String>>(&mut self, value: VALUE) -> &mut Self
[src]directory for writing results
pub fn prefix<VALUE: Into<String>>(&mut self, value: VALUE) -> &mut Self
[src]route prefixes
pub fn copy(&mut self, value: bool) -> &mut Self
[src]copy other non-hashed files from source dire to result dir?
pub fn follow_links(&mut self, value: bool) -> &mut Self
[src]follow symlinks?
-
pub fn build(&self) -> Result<Buster, BusterBuilderError>
[src]Builds a new
+Buster
.
pub fn no_hash(&mut self, value: Vec<&'a str>) -> &mut Self
[src]exclude these files for hashing. +They will be copied over without including a hash in the filename +Path should be relative to [self.source]
+
pub fn build(&self) -> Result<Buster<'a>, BusterBuilderError>
[src]Trait Implementations
impl Clone for BusterBuilder
[src]
fn clone(&self) -> BusterBuilder
[src]Returns a copy of the value. Read more
+Trait Implementations
impl<'a> Clone for BusterBuilder<'a>
[src]
fn clone(&self) -> BusterBuilder<'a>
[src]Returns a copy of the value. Read more
pub fn clone_from(&mut self, source: &Self)
1.0.0[src]Performs copy-assignment from
-source
. Read moreAuto Trait Implementations
impl RefUnwindSafe for BusterBuilder
impl Send for BusterBuilder
impl Sync for BusterBuilder
impl Unpin for BusterBuilder
impl UnwindSafe for BusterBuilder
Blanket Implementations
Auto Trait Implementations
impl<'a> RefUnwindSafe for BusterBuilder<'a>
impl<'a> Send for BusterBuilder<'a>
impl<'a> Sync for BusterBuilder<'a>
impl<'a> Unpin for BusterBuilder<'a>
impl<'a> UnwindSafe for BusterBuilder<'a>
Blanket Implementations
impl<T> BorrowMut<T> for T where
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T
[src]Mutably borrows from an owned value. Read more
impl<T> From<T> for T
[src]
pub fn from(t: T) -> T
[src]Performs the conversion.
diff --git a/implementors/core/clone/trait.Clone.js b/implementors/core/clone/trait.Clone.js index 10726e6..2e12455 100644 --- a/implementors/core/clone/trait.Clone.js +++ b/implementors/core/clone/trait.Clone.js @@ -1,3 +1,3 @@ (function() {var implementors = {}; -implementors["cache_buster"] = [{"text":"impl Clone for Buster","synthetic":false,"types":["cache_buster::processor::Buster"]},{"text":"impl Clone for BusterBuilder","synthetic":false,"types":["cache_buster::processor::BusterBuilder"]},{"text":"impl Clone for Files","synthetic":false,"types":["cache_buster::filemap::Files"]}]; +implementors["cache_buster"] = [{"text":"impl<'a> Clone for Buster<'a>","synthetic":false,"types":["cache_buster::processor::Buster"]},{"text":"impl<'a> Clone for BusterBuilder<'a>","synthetic":false,"types":["cache_buster::processor::BusterBuilder"]},{"text":"impl Clone for Files","synthetic":false,"types":["cache_buster::filemap::Files"]}]; if (window.register_implementors) {window.register_implementors(implementors);} else {window.pending_implementors = implementors;}})() \ No newline at end of file diff --git a/implementors/core/default/trait.Default.js b/implementors/core/default/trait.Default.js index 7ae7d05..5f19434 100644 --- a/implementors/core/default/trait.Default.js +++ b/implementors/core/default/trait.Default.js @@ -1,3 +1,3 @@ (function() {var implementors = {}; -implementors["cache_buster"] = [{"text":"impl Default for BusterBuilder","synthetic":false,"types":["cache_buster::processor::BusterBuilder"]}]; +implementors["cache_buster"] = [{"text":"impl<'a> Default for BusterBuilder<'a>","synthetic":false,"types":["cache_buster::processor::BusterBuilder"]}]; if (window.register_implementors) {window.register_implementors(implementors);} else {window.pending_implementors = implementors;}})() \ No newline at end of file diff --git a/implementors/core/fmt/trait.Debug.js b/implementors/core/fmt/trait.Debug.js index edb5538..3b93aa6 100644 --- a/implementors/core/fmt/trait.Debug.js +++ b/implementors/core/fmt/trait.Debug.js @@ -1,3 +1,3 @@ (function() {var implementors = {}; -implementors["cache_buster"] = [{"text":"impl Debug for Buster","synthetic":false,"types":["cache_buster::processor::Buster"]},{"text":"impl Debug for BusterBuilderError","synthetic":false,"types":["cache_buster::processor::BusterBuilderError"]},{"text":"impl Debug for Files","synthetic":false,"types":["cache_buster::filemap::Files"]}]; +implementors["cache_buster"] = [{"text":"impl<'a> Debug for Buster<'a>","synthetic":false,"types":["cache_buster::processor::Buster"]},{"text":"impl Debug for BusterBuilderError","synthetic":false,"types":["cache_buster::processor::BusterBuilderError"]},{"text":"impl Debug for Files","synthetic":false,"types":["cache_buster::filemap::Files"]}]; if (window.register_implementors) {window.register_implementors(implementors);} else {window.pending_implementors = implementors;}})() \ No newline at end of file diff --git a/implementors/core/marker/trait.Freeze.js b/implementors/core/marker/trait.Freeze.js index f713eb2..48b5a77 100644 --- a/implementors/core/marker/trait.Freeze.js +++ b/implementors/core/marker/trait.Freeze.js @@ -1,4 +1,4 @@ (function() {var implementors = {}; implementors["actix_web"] = [{"text":"impl Freeze for FILES","synthetic":true,"types":["actix_web::FILES"]},{"text":"impl Freeze for INDEX","synthetic":true,"types":["actix_web::INDEX"]},{"text":"impl Freeze for Asset","synthetic":true,"types":["actix_web::Asset"]},{"text":"impl Freeze for static_files","synthetic":true,"types":["actix_web::static_files"]},{"text":"impl Freeze for serve_index","synthetic":true,"types":["actix_web::serve_index"]},{"text":"impl Freeze for Favicons","synthetic":true,"types":["actix_web::Favicons"]},{"text":"impl Freeze for favicons","synthetic":true,"types":["actix_web::favicons"]}]; -implementors["cache_buster"] = [{"text":"impl Freeze for Buster","synthetic":true,"types":["cache_buster::processor::Buster"]},{"text":"impl Freeze for BusterBuilder","synthetic":true,"types":["cache_buster::processor::BusterBuilder"]},{"text":"impl Freeze for BusterBuilderError","synthetic":true,"types":["cache_buster::processor::BusterBuilderError"]},{"text":"impl Freeze for Files","synthetic":true,"types":["cache_buster::filemap::Files"]}]; +implementors["cache_buster"] = [{"text":"impl<'a> Freeze for Buster<'a>","synthetic":true,"types":["cache_buster::processor::Buster"]},{"text":"impl<'a> Freeze for BusterBuilder<'a>","synthetic":true,"types":["cache_buster::processor::BusterBuilder"]},{"text":"impl Freeze for BusterBuilderError","synthetic":true,"types":["cache_buster::processor::BusterBuilderError"]},{"text":"impl Freeze for Files","synthetic":true,"types":["cache_buster::filemap::Files"]}]; if (window.register_implementors) {window.register_implementors(implementors);} else {window.pending_implementors = implementors;}})() \ No newline at end of file diff --git a/implementors/core/marker/trait.Send.js b/implementors/core/marker/trait.Send.js index f5d5cb9..5402c6f 100644 --- a/implementors/core/marker/trait.Send.js +++ b/implementors/core/marker/trait.Send.js @@ -1,4 +1,4 @@ (function() {var implementors = {}; implementors["actix_web"] = [{"text":"impl Send for FILES","synthetic":true,"types":["actix_web::FILES"]},{"text":"impl Send for INDEX","synthetic":true,"types":["actix_web::INDEX"]},{"text":"impl Send for Asset","synthetic":true,"types":["actix_web::Asset"]},{"text":"impl Send for static_files","synthetic":true,"types":["actix_web::static_files"]},{"text":"impl Send for serve_index","synthetic":true,"types":["actix_web::serve_index"]},{"text":"impl Send for Favicons","synthetic":true,"types":["actix_web::Favicons"]},{"text":"impl Send for favicons","synthetic":true,"types":["actix_web::favicons"]}]; -implementors["cache_buster"] = [{"text":"impl Send for Buster","synthetic":true,"types":["cache_buster::processor::Buster"]},{"text":"impl Send for BusterBuilder","synthetic":true,"types":["cache_buster::processor::BusterBuilder"]},{"text":"impl Send for BusterBuilderError","synthetic":true,"types":["cache_buster::processor::BusterBuilderError"]},{"text":"impl Send for Files","synthetic":true,"types":["cache_buster::filemap::Files"]}]; +implementors["cache_buster"] = [{"text":"impl<'a> Send for Buster<'a>","synthetic":true,"types":["cache_buster::processor::Buster"]},{"text":"impl<'a> Send for BusterBuilder<'a>","synthetic":true,"types":["cache_buster::processor::BusterBuilder"]},{"text":"impl Send for BusterBuilderError","synthetic":true,"types":["cache_buster::processor::BusterBuilderError"]},{"text":"impl Send for Files","synthetic":true,"types":["cache_buster::filemap::Files"]}]; if (window.register_implementors) {window.register_implementors(implementors);} else {window.pending_implementors = implementors;}})() \ No newline at end of file diff --git a/implementors/core/marker/trait.Sync.js b/implementors/core/marker/trait.Sync.js index d0682f1..ffe724c 100644 --- a/implementors/core/marker/trait.Sync.js +++ b/implementors/core/marker/trait.Sync.js @@ -1,4 +1,4 @@ (function() {var implementors = {}; implementors["actix_web"] = [{"text":"impl Sync for FILES","synthetic":true,"types":["actix_web::FILES"]},{"text":"impl Sync for INDEX","synthetic":true,"types":["actix_web::INDEX"]},{"text":"impl Sync for Asset","synthetic":true,"types":["actix_web::Asset"]},{"text":"impl Sync for static_files","synthetic":true,"types":["actix_web::static_files"]},{"text":"impl Sync for serve_index","synthetic":true,"types":["actix_web::serve_index"]},{"text":"impl Sync for Favicons","synthetic":true,"types":["actix_web::Favicons"]},{"text":"impl Sync for favicons","synthetic":true,"types":["actix_web::favicons"]}]; -implementors["cache_buster"] = [{"text":"impl Sync for Buster","synthetic":true,"types":["cache_buster::processor::Buster"]},{"text":"impl Sync for BusterBuilder","synthetic":true,"types":["cache_buster::processor::BusterBuilder"]},{"text":"impl Sync for BusterBuilderError","synthetic":true,"types":["cache_buster::processor::BusterBuilderError"]},{"text":"impl Sync for Files","synthetic":true,"types":["cache_buster::filemap::Files"]}]; +implementors["cache_buster"] = [{"text":"impl<'a> Sync for Buster<'a>","synthetic":true,"types":["cache_buster::processor::Buster"]},{"text":"impl<'a> Sync for BusterBuilder<'a>","synthetic":true,"types":["cache_buster::processor::BusterBuilder"]},{"text":"impl Sync for BusterBuilderError","synthetic":true,"types":["cache_buster::processor::BusterBuilderError"]},{"text":"impl Sync for Files","synthetic":true,"types":["cache_buster::filemap::Files"]}]; if (window.register_implementors) {window.register_implementors(implementors);} else {window.pending_implementors = implementors;}})() \ No newline at end of file diff --git a/implementors/core/marker/trait.Unpin.js b/implementors/core/marker/trait.Unpin.js index d0516f2..af82811 100644 --- a/implementors/core/marker/trait.Unpin.js +++ b/implementors/core/marker/trait.Unpin.js @@ -1,4 +1,4 @@ (function() {var implementors = {}; implementors["actix_web"] = [{"text":"impl Unpin for FILES","synthetic":true,"types":["actix_web::FILES"]},{"text":"impl Unpin for INDEX","synthetic":true,"types":["actix_web::INDEX"]},{"text":"impl Unpin for Asset","synthetic":true,"types":["actix_web::Asset"]},{"text":"impl Unpin for static_files","synthetic":true,"types":["actix_web::static_files"]},{"text":"impl Unpin for serve_index","synthetic":true,"types":["actix_web::serve_index"]},{"text":"impl Unpin for Favicons","synthetic":true,"types":["actix_web::Favicons"]},{"text":"impl Unpin for favicons","synthetic":true,"types":["actix_web::favicons"]}]; -implementors["cache_buster"] = [{"text":"impl Unpin for Buster","synthetic":true,"types":["cache_buster::processor::Buster"]},{"text":"impl Unpin for BusterBuilder","synthetic":true,"types":["cache_buster::processor::BusterBuilder"]},{"text":"impl Unpin for BusterBuilderError","synthetic":true,"types":["cache_buster::processor::BusterBuilderError"]},{"text":"impl Unpin for Files","synthetic":true,"types":["cache_buster::filemap::Files"]}]; +implementors["cache_buster"] = [{"text":"impl<'a> Unpin for Buster<'a>","synthetic":true,"types":["cache_buster::processor::Buster"]},{"text":"impl<'a> Unpin for BusterBuilder<'a>","synthetic":true,"types":["cache_buster::processor::BusterBuilder"]},{"text":"impl Unpin for BusterBuilderError","synthetic":true,"types":["cache_buster::processor::BusterBuilderError"]},{"text":"impl Unpin for Files","synthetic":true,"types":["cache_buster::filemap::Files"]}]; if (window.register_implementors) {window.register_implementors(implementors);} else {window.pending_implementors = implementors;}})() \ No newline at end of file diff --git a/implementors/std/panic/trait.RefUnwindSafe.js b/implementors/std/panic/trait.RefUnwindSafe.js index 7f6fc58..a33209e 100644 --- a/implementors/std/panic/trait.RefUnwindSafe.js +++ b/implementors/std/panic/trait.RefUnwindSafe.js @@ -1,4 +1,4 @@ (function() {var implementors = {}; implementors["actix_web"] = [{"text":"impl RefUnwindSafe for FILES","synthetic":true,"types":["actix_web::FILES"]},{"text":"impl RefUnwindSafe for INDEX","synthetic":true,"types":["actix_web::INDEX"]},{"text":"impl RefUnwindSafe for Asset","synthetic":true,"types":["actix_web::Asset"]},{"text":"impl RefUnwindSafe for static_files","synthetic":true,"types":["actix_web::static_files"]},{"text":"impl RefUnwindSafe for serve_index","synthetic":true,"types":["actix_web::serve_index"]},{"text":"impl RefUnwindSafe for Favicons","synthetic":true,"types":["actix_web::Favicons"]},{"text":"impl RefUnwindSafe for favicons","synthetic":true,"types":["actix_web::favicons"]}]; -implementors["cache_buster"] = [{"text":"impl RefUnwindSafe for Buster","synthetic":true,"types":["cache_buster::processor::Buster"]},{"text":"impl RefUnwindSafe for BusterBuilder","synthetic":true,"types":["cache_buster::processor::BusterBuilder"]},{"text":"impl RefUnwindSafe for BusterBuilderError","synthetic":true,"types":["cache_buster::processor::BusterBuilderError"]},{"text":"impl RefUnwindSafe for Files","synthetic":true,"types":["cache_buster::filemap::Files"]}]; +implementors["cache_buster"] = [{"text":"impl<'a> RefUnwindSafe for Buster<'a>","synthetic":true,"types":["cache_buster::processor::Buster"]},{"text":"impl<'a> RefUnwindSafe for BusterBuilder<'a>","synthetic":true,"types":["cache_buster::processor::BusterBuilder"]},{"text":"impl RefUnwindSafe for BusterBuilderError","synthetic":true,"types":["cache_buster::processor::BusterBuilderError"]},{"text":"impl RefUnwindSafe for Files","synthetic":true,"types":["cache_buster::filemap::Files"]}]; if (window.register_implementors) {window.register_implementors(implementors);} else {window.pending_implementors = implementors;}})() \ No newline at end of file diff --git a/implementors/std/panic/trait.UnwindSafe.js b/implementors/std/panic/trait.UnwindSafe.js index cf90c5f..380153d 100644 --- a/implementors/std/panic/trait.UnwindSafe.js +++ b/implementors/std/panic/trait.UnwindSafe.js @@ -1,4 +1,4 @@ (function() {var implementors = {}; implementors["actix_web"] = [{"text":"impl UnwindSafe for FILES","synthetic":true,"types":["actix_web::FILES"]},{"text":"impl UnwindSafe for INDEX","synthetic":true,"types":["actix_web::INDEX"]},{"text":"impl UnwindSafe for Asset","synthetic":true,"types":["actix_web::Asset"]},{"text":"impl UnwindSafe for static_files","synthetic":true,"types":["actix_web::static_files"]},{"text":"impl UnwindSafe for serve_index","synthetic":true,"types":["actix_web::serve_index"]},{"text":"impl UnwindSafe for Favicons","synthetic":true,"types":["actix_web::Favicons"]},{"text":"impl UnwindSafe for favicons","synthetic":true,"types":["actix_web::favicons"]}]; -implementors["cache_buster"] = [{"text":"impl UnwindSafe for Buster","synthetic":true,"types":["cache_buster::processor::Buster"]},{"text":"impl UnwindSafe for BusterBuilder","synthetic":true,"types":["cache_buster::processor::BusterBuilder"]},{"text":"impl UnwindSafe for BusterBuilderError","synthetic":true,"types":["cache_buster::processor::BusterBuilderError"]},{"text":"impl UnwindSafe for Files","synthetic":true,"types":["cache_buster::filemap::Files"]}]; +implementors["cache_buster"] = [{"text":"impl<'a> UnwindSafe for Buster<'a>","synthetic":true,"types":["cache_buster::processor::Buster"]},{"text":"impl<'a> UnwindSafe for BusterBuilder<'a>","synthetic":true,"types":["cache_buster::processor::BusterBuilder"]},{"text":"impl UnwindSafe for BusterBuilderError","synthetic":true,"types":["cache_buster::processor::BusterBuilderError"]},{"text":"impl UnwindSafe for Files","synthetic":true,"types":["cache_buster::filemap::Files"]}]; if (window.register_implementors) {window.register_implementors(implementors);} else {window.pending_implementors = implementors;}})() \ No newline at end of file diff --git a/search-index.js b/search-index.js index af68810..a052920 100644 --- a/search-index.js +++ b/search-index.js @@ -1,5 +1,5 @@ var searchIndex = JSON.parse('{\ "actix_web":{"doc":"","t":[3,17,3,3,3,12,12,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,3,11,11,11,11,11,11,11,11,11,11,11,5,5,0,11,11,11,11,11,11,11,11,11,11,11,11,11,5,11,11,11,3,5,3,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,5],"n":["Asset","CACHE_AGE","FILES","Favicons","INDEX","__private_field","__private_field","borrow","borrow","borrow","borrow","borrow","borrow","borrow","borrow_mut","borrow_mut","borrow_mut","borrow_mut","borrow_mut","borrow_mut","borrow_mut","deref","deref","favicons","from","from","from","from","from","from","from","get","get","get","get","handle_assets","handle_favicons","index","initialize","initialize","into","into","into","into","into","into","into","iter","iter","iter","iter","main","register","register","register","serve_index","services","static_files","try_from","try_from","try_from","try_from","try_from","try_from","try_from","try_into","try_into","try_into","try_into","try_into","try_into","try_into","type_id","type_id","type_id","type_id","type_id","type_id","type_id","vzip","vzip","vzip","vzip","vzip","vzip","vzip","get_index"],"q":["actix_web","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","actix_web::index"],"d":["Embed files. Or not. You can also read files dynamically","Set a riddicolusly high cache age","create filemap","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","",""],"i":[0,0,0,0,0,1,2,1,2,3,4,5,6,7,1,2,3,4,5,6,7,1,2,0,1,2,3,4,5,6,7,3,3,6,6,0,0,0,1,2,1,2,3,4,5,6,7,3,3,6,6,0,4,5,7,0,0,0,1,2,3,4,5,6,7,1,2,3,4,5,6,7,1,2,3,4,5,6,7,1,2,3,4,5,6,7,0],"f":[null,null,null,null,null,null,null,[[]],[[]],[[]],[[]],[[]],[[]],[[]],[[]],[[]],[[]],[[]],[[]],[[]],[[]],[[],["files",3]],[[],["string",3]],null,[[]],[[]],[[]],[[]],[[]],[[]],[[]],[[["str",15]],[["option",4],["cow",4]]],[[["str",15]],[["option",4],["cow",4]]],[[["str",15]],[["option",4],["cow",4]]],[[["str",15]],[["option",4],["cow",4]]],[[["str",15]],["httpresponse",3]],[[["str",15]],["httpresponse",3]],null,[[]],[[]],[[]],[[]],[[]],[[]],[[]],[[]],[[]],[[]],[[],["filenames",4]],[[],["filenames",4]],[[]],[[],["result",6]],[[["appservice",3]]],[[["appservice",3]]],[[["appservice",3]]],null,[[["serviceconfig",3]]],null,[[],["result",4]],[[],["result",4]],[[],["result",4]],[[],["result",4]],[[],["result",4]],[[],["result",4]],[[],["result",4]],[[],["result",4]],[[],["result",4]],[[],["result",4]],[[],["result",4]],[[],["result",4]],[[],["result",4]],[[],["result",4]],[[],["typeid",3]],[[],["typeid",3]],[[],["typeid",3]],[[],["typeid",3]],[[],["typeid",3]],[[],["typeid",3]],[[],["typeid",3]],[[]],[[]],[[]],[[]],[[]],[[]],[[]],[[],["string",3]]],"p":[[3,"FILES"],[3,"INDEX"],[3,"Asset"],[3,"static_files"],[3,"serve_index"],[3,"Favicons"],[3,"favicons"]]},\ -"cache_buster":{"doc":"What is cache busting?","t":[17,0,0,3,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,3,3,4,13,13,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11],"n":["CACHE_BUSTER_DATA_FILE","filemap","processor","Files","borrow","borrow_mut","clone","clone_into","deserialize","eq","fmt","from","get","get_full_path","into","ne","new","serialize","to_owned","try_from","try_into","type_id","Buster","BusterBuilder","BusterBuilderError","UninitializedField","ValidationError","borrow","borrow","borrow","borrow_mut","borrow_mut","borrow_mut","build","clone","clone","clone_into","clone_into","copy","default","fmt","fmt","fmt","follow_links","from","from","from","from","from","into","into","into","mime_types","prefix","process","result","source","to_owned","to_owned","to_string","try_from","try_from","try_from","try_into","try_into","try_into","type_id","type_id","type_id"],"q":["cache_buster","","","cache_buster::filemap","","","","","","","","","","","","","","","","","","","cache_buster::processor","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","",""],"d":["file to which filemap is written during compilation …","Module describing runtime compoenet for fetching modified …","Module describing file processor that changes filenames …","Filemap struct","","","","","","","","","Get relative file path","Get file path","","","Load filemap in main program. Should be called from main …","","","","","","Configuration for setting up cache-busting","Builder forBuster
.","Error type for BusterBuilder","Uninitialized field","Custom validation error","","","","","","","Builds a newBuster
.","","","","","copy other non-hashed files from source dire to result …","","","","","follow symlinks?","","","","","","","","","mime_types for hashing","route prefixes","Processes files.","directory for writing results","source directory","","","","","","","","","","","",""],"i":[0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,2,2,3,4,2,3,4,2,4,3,4,3,4,4,4,3,2,2,4,3,4,2,2,2,3,4,2,4,4,3,4,4,3,4,2,3,4,2,3,4,2,3,4,2],"f":[null,null,null,null,[[]],[[]],[[],["files",3]],[[]],[[],["result",4]],[[["files",3]],["bool",15]],[[["formatter",3]],["result",6]],[[]],[[["str",15]],[["str",15],["option",4]]],[[["str",15]],[["option",4],["string",3]]],[[]],[[["files",3]],["bool",15]],[[["str",15]]],[[],["result",4]],[[]],[[],["result",4]],[[],["result",4]],[[],["typeid",3]],null,null,null,null,null,[[]],[[]],[[]],[[]],[[]],[[]],[[],[["buster",3],["result",4],["busterbuildererror",4]]],[[],["buster",3]],[[],["busterbuilder",3]],[[]],[[]],[[["bool",15]]],[[]],[[["formatter",3]],["result",6]],[[["formatter",3]],["result",6]],[[["formatter",3]],["result",6]],[[["bool",15]]],[[]],[[]],[[["string",3]]],[[]],[[["uninitializedfielderror",3]]],[[]],[[]],[[]],[[["mime",3],["vec",3]]],[[["into",8],["string",3]]],[[],[["result",4],["error",3]]],[[["into",8],["string",3]]],[[["into",8],["string",3]]],[[]],[[]],[[],["string",3]],[[],["result",4]],[[],["result",4]],[[],["result",4]],[[],["result",4]],[[],["result",4]],[[],["result",4]],[[],["typeid",3]],[[],["typeid",3]],[[],["typeid",3]]],"p":[[3,"Files"],[4,"BusterBuilderError"],[3,"Buster"],[3,"BusterBuilder"]]}\ +"cache_buster":{"doc":"What is cache busting?","t":[17,0,0,3,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,3,3,4,13,13,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11],"n":["CACHE_BUSTER_DATA_FILE","filemap","processor","Files","borrow","borrow_mut","clone","clone_into","deserialize","eq","fmt","from","get","get_full_path","into","ne","new","serialize","to_owned","try_from","try_into","type_id","Buster","BusterBuilder","BusterBuilderError","UninitializedField","ValidationError","borrow","borrow","borrow","borrow_mut","borrow_mut","borrow_mut","build","clone","clone","clone_into","clone_into","copy","default","fmt","fmt","fmt","follow_links","from","from","from","from","from","into","into","into","mime_types","no_hash","prefix","process","result","source","to_owned","to_owned","to_string","try_from","try_from","try_from","try_into","try_into","try_into","type_id","type_id","type_id"],"q":["cache_buster","","","cache_buster::filemap","","","","","","","","","","","","","","","","","","","cache_buster::processor","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","",""],"d":["file to which filemap is written during compilation …","Module describing runtime compoenet for fetching modified …","Module describing file processor that changes filenames …","Filemap struct","","","","","","","","","Get relative file path","Get file path","","","Load filemap in main program. Should be called from main …","","","","","","Configuration for setting up cache-busting","Builder forBuster
.","Error type for BusterBuilder","Uninitialized field","Custom validation error","","","","","","","Builds a newBuster
.","","","","","copy other non-hashed files from source dire to result …","","","","","follow symlinks?","","","","","","","","","mime_types for hashing","exclude these files for hashing. They will be copied over …","route prefixes","Processes files.","directory for writing results","source directory","","","","","","","","","","","",""],"i":[0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,2,2,3,2,4,3,2,4,3,3,4,3,4,3,3,2,2,4,3,3,2,2,2,4,3,2,4,3,3,3,4,3,3,3,4,2,3,2,4,3,2,4,3,2,4],"f":[null,null,null,null,[[]],[[]],[[],["files",3]],[[]],[[],["result",4]],[[["files",3]],["bool",15]],[[["formatter",3]],["result",6]],[[]],[[["str",15]],[["str",15],["option",4]]],[[["str",15]],[["option",4],["string",3]]],[[]],[[["files",3]],["bool",15]],[[["str",15]]],[[],["result",4]],[[]],[[],["result",4]],[[],["result",4]],[[],["typeid",3]],null,null,null,null,null,[[]],[[]],[[]],[[]],[[]],[[]],[[],[["result",4],["buster",3],["busterbuildererror",4]]],[[],["busterbuilder",3]],[[],["buster",3]],[[]],[[]],[[["bool",15]]],[[]],[[["formatter",3]],["result",6]],[[["formatter",3]],["result",6]],[[["formatter",3]],["result",6]],[[["bool",15]]],[[]],[[["uninitializedfielderror",3]]],[[]],[[["string",3]]],[[]],[[]],[[]],[[]],[[["mime",3],["vec",3]]],[[["vec",3],["str",15]]],[[["into",8],["string",3]]],[[],[["result",4],["error",3]]],[[["into",8],["string",3]]],[[["into",8],["string",3]]],[[]],[[]],[[],["string",3]],[[],["result",4]],[[],["result",4]],[[],["result",4]],[[],["result",4]],[[],["result",4]],[[],["result",4]],[[],["typeid",3]],[[],["typeid",3]],[[],["typeid",3]]],"p":[[3,"Files"],[4,"BusterBuilderError"],[3,"BusterBuilder"],[3,"Buster"]]}\ }'); if (window.initSearch) {window.initSearch(searchIndex)}; \ No newline at end of file diff --git a/src/cache_buster/processor.rs.html b/src/cache_buster/processor.rs.html index 4a20f97..119aed7 100644 --- a/src/cache_buster/processor.rs.html +++ b/src/cache_buster/processor.rs.html @@ -351,6 +351,61 @@ 348 349 350 +351 +352 +353 +354 +355 +356 +357 +358 +359 +360 +361 +362 +363 +364 +365 +366 +367 +368 +369 +370 +371 +372 +373 +374 +375 +376 +377 +378 +379 +380 +381 +382 +383 +384 +385 +386 +387 +388 +389 +390 +391 +392 +393 +394 +395 +396 +397 +398 +399 +400 +401 +402 +403 +404 +405/* * Copyright (C) 2021 Aravinth Manivannan <realaravinth@batsense.net> @@ -405,7 +460,8 @@ /// Configuration for setting up cache-busting #[derive(Debug, Clone, Builder)] -pub struct Buster { +#[builder(build_fn(validate = "Self::validate"))] +pub struct Buster<'a> { /// source directory #[builder(setter(into))] source: String, @@ -421,9 +477,30 @@ copy: bool, /// follow symlinks? follow_links: bool, + /// exclude these files for hashing. + /// They will be copied over without including a hash in the filename + /// Path should be relative to [self.source] + #[builder(default)] + no_hash: Vec<&'a str>, } -impl Buster { +impl<'a> BusterBuilder<'a> { + fn validate(&self) -> Result<(), String> { + for file in self.no_hash.iter() { + for file in file.iter() { + if !Path::new(&self.source.as_ref().unwrap()) + .join(file) + .exists() + { + return Err(format!("File {} doesn't exist", file)); + } + } + } + Ok(()) + } +} + +impl<'a> Buster<'a> { // creates base_dir to output files to fn init(&self) -> Result<(), Error> { let res = Path::new(&self.result); @@ -461,7 +538,7 @@ let entry = entry?; let path = entry.path(); - if !path.is_dir() { + if !path.is_dir() && !self.no_hash.contains(&path.to_str().unwrap()) { let path = Path::new(&path); for mime_type in self.mime_types.iter() { @@ -504,7 +581,7 @@ } // helper fn to generate filemap - fn gen_map<'a>(&self, source: &'a Path, name: &str) -> (&'a Path, PathBuf) { + fn gen_map<'b>(&self, source: &'b Path, name: &str) -> (&'b Path, PathBuf) { let rel_location = source.strip_prefix(&self.source).unwrap().parent().unwrap(); if let Some(prefix) = &self.prefix { //panic!("{}", &prefix); @@ -672,6 +749,8 @@ mime::IMAGE_GIF, ]; + let no_hash = vec!["bell.svg", "eye.svg", "a/b/c/d/s/d/svg/10.svg"]; + let config = BusterBuilder::default() .source("./dist") .result("/tmp/prod2i") @@ -679,6 +758,7 @@ .copy(true) .follow_links(true) .prefix("/test") + .no_hash(no_hash.clone()) .build() .unwrap(); @@ -686,6 +766,14 @@ let mut files = Files::load(); if let Some(prefix) = &config.prefix { + no_hash.iter().for_each(|file| { + files.map.iter().any(|(k, v)| { + let dest = Path::new(&v[prefix.len()..]); + let no_hash = Path::new(file); + k == file && dest.exists() && no_hash.file_name() == dest.file_name() + }); + }); + for (k, v) in files.map.drain() { let src = Path::new(&k); let dest = Path::new(&v[prefix.len()..]); @@ -697,6 +785,28 @@ cleanup(&config); } + #[test] + fn no_hash_validation_works() { + let types = vec![ + mime::IMAGE_PNG, + mime::IMAGE_SVG, + mime::IMAGE_JPEG, + mime::IMAGE_GIF, + ]; + + let no_hash = vec!["bbell.svg", "eye.svg", "a/b/c/d/s/d/svg/10.svg"]; + assert!(BusterBuilder::default() + .source("./dist") + .result("/tmp/prod2i") + .mime_types(types) + .copy(true) + .follow_links(true) + .prefix("/test") + .no_hash(no_hash.clone()) + .build() + .is_err()) + } + pub fn runner() { prefix_works(); hasher_works();