Status

Enum Status 

Source
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

Source

pub fn new(response: &Response, accepted: &HashSet<StatusCode>) -> Self

Create a status object from a response and the set of accepted status codes

Source

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.

Source

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.

Source

pub const fn is_success(&self) -> bool

Returns true if the check was successful

Source

pub const fn is_error(&self) -> bool

Returns true if the check was not successful

Source

pub const fn is_excluded(&self) -> bool

Returns true if the check was excluded

Source

pub const fn is_timeout(&self) -> bool

Returns true if a check took too long to complete

Source

pub const fn is_unsupported(&self) -> bool

Returns true if a URI is unsupported

Source

pub const fn icon(&self) -> &str

Return a unicode icon to visualize the status

Source

pub fn code(&self) -> Option<StatusCode>

Return the HTTP status code (if any)

Source

pub fn code_as_string(&self) -> String

Return the HTTP status code as string (if any)

Source

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 Debug for Status

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Display for Status

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl From<&Status> for CacheStatus

Source§

fn from(s: &Status) -> Self

Converts to this type from the input type.
Source§

impl From<Error> for Status

Source§

fn from(e: Error) -> Self

Converts to this type from the input type.
Source§

impl From<ErrorKind> for Status

Source§

fn from(e: ErrorKind) -> Self

Converts to this type from the input type.
Source§

impl Hash for Status

Source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl PartialEq for Status

Source§

fn eq(&self, other: &Status) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Serialize for Status

Source§

fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
where S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl Eq for Status

Source§

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> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

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
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

impl<T> ToStringFallible for T
where T: Display,

Source§

fn try_to_string(&self) -> Result<String, TryReserveError>

ToString::to_string, but without panic on OOM.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

impl<T> ErasedDestructor for T
where T: 'static,