pub struct File { /* private fields */ }
Expand description
A file response.
Implementations
sourceimpl File
impl File
sourcepub fn path(&self) -> &Path
pub fn path(&self) -> &Path
Extract the &Path
of the file this Response
delivers.
Example
The example below changes the Content-Type response header for every file called video.mp4
.
use warp::{Filter, reply::Reply};
let route = warp::path("static")
.and(warp::fs::dir("/www/static"))
.map(|reply: warp::filters::fs::File| {
if reply.path().ends_with("video.mp4") {
warp::reply::with_header(reply, "Content-Type", "video/mp4").into_response()
} else {
reply.into_response()
}
});
Trait Implementations
Auto Trait Implementations
impl !RefUnwindSafe for File
impl Send for File
impl Sync for File
impl Unpin for File
impl !UnwindSafe for File
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcepub fn borrow_mut(&mut self) -> &mut T
pub fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<T> Instrument for T
impl<T> Instrument for T
sourcefn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Instruments this type with the provided Span
, returning an
Instrumented
wrapper. Read more
sourcefn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
impl<T> Same<T> for T
impl<T> Same<T> for T
type Output = T
type Output = T
Should always be Self