pub enum ServeError {
MethodNotAllowed,
InvalidPath,
NotModified,
PreconditionFailed,
RangeNotSatisfied(u64),
NotFound,
Io(Error),
}
Expand description
high level error types for serving file. see into_response_from and into_response for way of converting error to Response type.
Variants§
MethodNotAllowed
request method is not allowed. only GET/HEAD methods are allowed.
InvalidPath
requested file path is invalid.
NotModified
requested file has not been modified.
PreconditionFailed
requested file has been modified before given precondition time.
RangeNotSatisfied(u64)
requested file range is not satisfied. u64 is the max range of file.
NotFound
can not find requested file.
Io(Error)
I/O error from file system.
Implementations§
Source§impl ServeError
impl ServeError
Sourcepub fn into_response_from<Ext>(self, req: Request<Ext>) -> Response<()>
pub fn into_response_from<Ext>(self, req: Request<Ext>) -> Response<()>
produce a response from error. an existing request is received for inherent it’s extension data and reuse it’s heap allocation.
§Examples
#[derive(Clone)]
struct User;
let mut req = Request::new(());
req.extensions_mut().insert(User); // data type were inserted into request extension.
let mut res = ServeError::NotFound.into_response_from(req);
res.extensions_mut().remove::<User>().unwrap(); // data type is moved to response.
Sourcepub fn into_response(self) -> Response<()>
pub fn into_response(self) -> Response<()>
produce a response from error.
Trait Implementations§
Source§impl Debug for ServeError
impl Debug for ServeError
Source§impl Display for ServeError
impl Display for ServeError
Source§impl Error for ServeError
impl Error for ServeError
1.30.0 · Source§fn source(&self) -> Option<&(dyn Error + 'static)>
fn source(&self) -> Option<&(dyn Error + 'static)>
Returns the lower-level source of this error, if any. Read more
1.0.0 · Source§fn description(&self) -> &str
fn description(&self) -> &str
👎Deprecated since 1.42.0: use the Display impl or to_string()
Auto Trait Implementations§
impl Freeze for ServeError
impl !RefUnwindSafe for ServeError
impl Send for ServeError
impl Sync for ServeError
impl Unpin for ServeError
impl !UnwindSafe for ServeError
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