pub struct FileCache<T: AsyncFromStrWithState> { /* private fields */ }
Implementations§
source§impl<T: AsyncFromStrWithState> FileCache<T>
impl<T: AsyncFromStrWithState> FileCache<T>
pub fn new() -> Self
sourcepub fn add_static(&mut self, path: PathBuf, contents: T)
pub fn add_static(&mut self, path: PathBuf, contents: T)
Adds a static file to the cache so that it will never be looked up from the disk
sourcepub async fn get(&self, app_state: &AppState, path: &Path) -> Result<Arc<T>>
pub async fn get(&self, app_state: &AppState, path: &Path) -> Result<Arc<T>>
Gets a file from the cache, or loads it from the file system if it’s not there This is a privileged operation; it should not be used for user-provided paths
sourcepub async fn get_with_privilege(
&self,
app_state: &AppState,
path: &Path,
privileged: bool,
) -> Result<Arc<T>>
pub async fn get_with_privilege( &self, app_state: &AppState, path: &Path, privileged: bool, ) -> Result<Arc<T>>
Gets a file from the cache, or loads it from the file system if it’s not there The privileged parameter is used to determine whether the access should be denied if the file is in the sqlpage/ config directory
Trait Implementations§
Auto Trait Implementations§
impl<T> Freeze for FileCache<T>
impl<T> !RefUnwindSafe for FileCache<T>
impl<T> Send for FileCache<T>
impl<T> Sync for FileCache<T>
impl<T> Unpin for FileCache<T>
impl<T> !UnwindSafe for FileCache<T>
Blanket Implementations§
source§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
source§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
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> 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> IntoEither for T
impl<T> IntoEither for T
source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moresource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more