pub enum Status {
Ok(StatusCode),
Error(ErrorKind),
Timeout(Option<StatusCode>),
Redirected(StatusCode),
UnknownStatusCode(StatusCode),
Excluded,
Unsupported(ErrorKind),
Cached(CacheStatus),
}
Expand description
Response status of the request.
Variants§
Ok(StatusCode)
Request was successful
Error(ErrorKind)
Failed request
Timeout(Option<StatusCode>)
Request timed out
Redirected(StatusCode)
Got redirected to different resource
UnknownStatusCode(StatusCode)
The given status code is not known by lychee
Excluded
Resource was excluded from checking
Unsupported(ErrorKind)
The request type is currently not supported,
for example when the URL scheme is slack://
.
See https://github.com/lycheeverse/lychee/issues/199
Cached(CacheStatus)
Cached request status from previous run
Implementations§
Source§impl Status
impl Status
Sourcepub fn new(response: &Response, accepted: &HashSet<StatusCode>) -> Self
pub fn new(response: &Response, accepted: &HashSet<StatusCode>) -> Self
Create a status object from a response and the set of accepted status codes
Sourcepub fn from_cache_status(s: CacheStatus, accepted: &HashSet<u16>) -> Self
pub fn from_cache_status(s: CacheStatus, accepted: &HashSet<u16>) -> Self
Create a status object from a cached status (from a previous run of lychee) and the set of accepted status codes.
The set of accepted status codes can change between runs, necessitating more complex logic than just using the cached status.
Note that the accepted status codes are not of type StatusCode
,
because they are provided by the user and can be invalid according to
the HTTP spec and IANA, but the user might still want to accept them.
Sourcepub fn details(&self) -> Option<String>
pub fn details(&self) -> Option<String>
Return more details about the status (if any)
Which additional information we can extract depends on the underlying request type. The output is purely meant for humans and future changes are expected.
It is modeled after reqwest’s details
method.
Sourcepub const fn is_success(&self) -> bool
pub const fn is_success(&self) -> bool
Returns true
if the check was successful
Sourcepub const fn is_excluded(&self) -> bool
pub const fn is_excluded(&self) -> bool
Returns true
if the check was excluded
Sourcepub const fn is_timeout(&self) -> bool
pub const fn is_timeout(&self) -> bool
Returns true
if a check took too long to complete
Sourcepub const fn is_unsupported(&self) -> bool
pub const fn is_unsupported(&self) -> bool
Returns true
if a URI is unsupported
Sourcepub fn code(&self) -> Option<StatusCode>
pub fn code(&self) -> Option<StatusCode>
Return the HTTP status code (if any)
Sourcepub fn code_as_string(&self) -> String
pub fn code_as_string(&self) -> String
Return the HTTP status code as string (if any)
Sourcepub const fn is_unknown(&self) -> bool
pub const fn is_unknown(&self) -> bool
Returns true if the status code is unknown (i.e. not a valid HTTP status code)
For example, 200
is a valid HTTP status code,
while 999
is not.
Trait Implementations§
Source§impl From<&Status> for CacheStatus
impl From<&Status> for CacheStatus
impl Eq for Status
impl StructuralPartialEq for Status
Auto Trait Implementations§
impl Freeze for Status
impl !RefUnwindSafe for Status
impl Send for Status
impl Sync for Status
impl Unpin for Status
impl !UnwindSafe for Status
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
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key
and return true
if they are equal.Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
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>
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>
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 moreSource§impl<T> Pointable for T
impl<T> Pointable for T
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.