Crate lychee_lib

source ·
Expand description

lychee-lib is the library component of lychee, and is used for checking links.

“Hello world” example:

use lychee_lib::Result;

#[tokio::main]
async fn main() -> Result<()> {
  let response = lychee_lib::check("https://github.com/lycheeverse/lychee").await?;
  println!("{response}");
  Ok(())
}

For more specific use-cases you can build a lychee client yourself, using the ClientBuilder which can be used to configure and run your own link checker and grants full flexibility:

use lychee_lib::{ClientBuilder, Result, Status};

#[tokio::main]
async fn main() -> Result<()> {
  let client = ClientBuilder::default().client()?;
  let response = client.check("https://github.com/lycheeverse/lychee").await?;
  assert!(response.status().is_success());
  Ok(())
}

Modules§

  • A pool of clients, to handle concurrent checks
  • Functionality to extract URIs from inputs
  • Filters are a way to define behavior when encountering URIs that need to be treated differently, such as local IPs or e-mail addresses
  • Remapping rules which allow to map URLs matching a pattern to a different URL.

Structs§

  • AcceptRange specifies which HTTP status codes are accepted and considered successful when checking a remote URL.
  • An AcceptSelector determines if a returned HTTP status code should be accepted and thus counted as a valid (not broken) link.
  • BasicAuthCredentials contains a pair of basic auth values consisting of a username and password.
  • Extracts basic auth credentials from a given URI. Credentials are extracted if the URI matches one of the provided BasicAuthSelector instances.
  • BasicAuthSelector provides basic auth credentials for URLs which match the specified regex. This allows users to set different credentials based on the URLs they want to target.
  • Handles incoming requests and returns responses.
  • Builder for Client.
  • Collector keeps the state of link collection It drives the link extraction from inputs
  • A wrapper around reqwest_cookie_store::CookieStore
  • Exclude configuration for the link checker. You can ignore links based on regex patterns.
  • A generic URI filter Used to decide if a given URI should be checked or skipped
  • Include configuration for the link checker. You can include links based on regex patterns
  • Lychee Input with optional file hint for parsing
  • Encapsulates the content for a given input
  • A request type that can be handle by lychee
  • Response type returned by lychee after checking a URI
  • Encapsulates the state of a URI check
  • Lychee’s own representation of a URI, which encapsulates all supported formats.

Enums§

  • The [AcceptRangeParseError] indicates that the parsing process of an AcceptRange from a string failed due to various underlying reasons.
  • When encountering links without a full domain in a document, the base determines where this resource can be found. Both, local and remote targets are supported.
  • Representation of the status of a cached request. This is kept simple on purpose because the type gets serialized to a cache file and might need to be parsed by other tools or edited by humans.
  • Kinds of status errors Note: The error messages can change over time, so don’t match on the output
  • FileType defines which file types lychee can handle
  • Input types which lychee supports
  • Response status of the request.

Constants§

Functions§

  • A shorthand function to check a single URI.

Type Aliases§