pub struct CacheBuster { /* private fields */ }
Implementations§
Source§impl CacheBuster
impl CacheBuster
pub fn new(asset_directory: &str) -> Self
pub fn gen_cache(&mut self)
Sourcepub fn get_file(&self, original_asset_file_path: &str) -> String
pub fn get_file(&self, original_asset_file_path: &str) -> String
Takes a path from root domain to a static asset (as it would be called from a browser, so with a leading slash) and returns the version of the filepath that contains a unique hash.
e.g. “/static/image/favicon/favicon.ico” -> “/static/image/favicon/favicon.66189abc248d80832e458ee37e93c9e8.ico”
§Panics
Panics if the file is not found in the cache.
pub fn get_cache(&self) -> BTreeMap<String, String>
Sourcepub fn print_to_file(&self, output_dir: &str)
pub fn print_to_file(&self, output_dir: &str)
§Panics
Panics if the file cannot be created or written to.
Sourcepub fn update_source_map_references(&self)
pub fn update_source_map_references(&self)
Updates the sourceMappingURL comment in .js
files to point to the hashed .js.map
file.
§Panics
Panics if the file cannot be read or parsed.
Sourcepub async fn never_cache_middleware(
req: Request,
next: Next,
) -> Result<Response, StatusCode>
pub async fn never_cache_middleware( req: Request, next: Next, ) -> Result<Response, StatusCode>
Middleware to set never-cache headers for all responses.
§Errors
Will return Error
if the request cannot be processed.
Sourcepub async fn forever_cache_middleware(
req: Request,
next: Next,
) -> Result<Response, StatusCode>
pub async fn forever_cache_middleware( req: Request, next: Next, ) -> Result<Response, StatusCode>
Trait Implementations§
Source§impl Clone for CacheBuster
impl Clone for CacheBuster
Source§fn clone(&self) -> CacheBuster
fn clone(&self) -> CacheBuster
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moreSource§impl Debug for CacheBuster
impl Debug for CacheBuster
Auto Trait Implementations§
impl Freeze for CacheBuster
impl RefUnwindSafe for CacheBuster
impl Send for CacheBuster
impl Sync for CacheBuster
impl Unpin for CacheBuster
impl UnwindSafe for CacheBuster
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt for Twhere
T: ?Sized,
Source§impl<T> ToStringFallible for Twhere
T: Display,
impl<T> ToStringFallible for Twhere
T: Display,
Source§fn try_to_string(&self) -> Result<String, TryReserveError>
fn try_to_string(&self) -> Result<String, TryReserveError>
ToString::to_string
, but without panic on OOM.