Struct salvo::prelude::StaticFile
source · pub struct StaticFile(/* private fields */);
Available on crate feature
serve-static
only.Expand description
StaticFile
is a handler that serves a single file.
Implementations§
source§impl StaticFile
impl StaticFile
sourcepub fn new(path: impl Into<PathBuf>) -> StaticFile
pub fn new(path: impl Into<PathBuf>) -> StaticFile
Create a new StaticFile
.
sourcepub fn chunk_size(self, size: u64) -> StaticFile
pub fn chunk_size(self, size: u64) -> StaticFile
During the file chunk read, the maximum read size at one time will affect the access experience and the demand for server memory.
Please set it according to your own situation.
The default is 1M.
Trait Implementations§
source§impl Clone for StaticFile
impl Clone for StaticFile
source§fn clone(&self) -> StaticFile
fn clone(&self) -> StaticFile
Returns a copy 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 Handler for StaticFile
impl Handler for StaticFile
source§fn handle<'life0, 'life1, 'life2, 'life3, 'life4, 'async_trait>(
&'life0 self,
req: &'life1 mut Request,
depot: &'life2 mut Depot,
res: &'life3 mut Response,
ctrl: &'life4 mut FlowCtrl
) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
'life3: 'async_trait,
'life4: 'async_trait,
StaticFile: 'async_trait,
fn handle<'life0, 'life1, 'life2, 'life3, 'life4, 'async_trait>(
&'life0 self,
req: &'life1 mut Request,
depot: &'life2 mut Depot,
res: &'life3 mut Response,
ctrl: &'life4 mut FlowCtrl
) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
'life3: 'async_trait,
'life4: 'async_trait,
StaticFile: 'async_trait,
Handle http request.
Auto Trait Implementations§
impl Freeze for StaticFile
impl RefUnwindSafe for StaticFile
impl Send for StaticFile
impl Sync for StaticFile
impl Unpin for StaticFile
impl UnwindSafe for StaticFile
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