mirror of
https://github.com/Hopiu/lychee.git
synced 2026-04-06 22:40:58 +00:00
Makes for arguably cleaner-looking code. The downside is that the MSRV is 1.58 https://blog.rust-lang.org/2022/01/13/Rust-1.58.0.html Given that nobody uses lychee as a library yet and we have precompiled binaries, it's an acceptable tradeoff. My little research revealed that this is a much-liked feature: https://twitter.com/matthiasendler/status/1483895557621960715
90 lines
2.6 KiB
Rust
90 lines
2.6 KiB
Rust
//! `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(())
|
|
//! }
|
|
//! ```
|
|
//!
|
|
//! [`lychee`]: https://github.com/lycheeverse/lychee
|
|
#![warn(clippy::all, clippy::pedantic)]
|
|
#![warn(
|
|
absolute_paths_not_starting_with_crate,
|
|
rustdoc::invalid_html_tags,
|
|
missing_copy_implementations,
|
|
missing_debug_implementations,
|
|
semicolon_in_expressions_from_macros,
|
|
unreachable_pub,
|
|
unused_crate_dependencies,
|
|
unused_extern_crates,
|
|
variant_size_differences,
|
|
clippy::missing_const_for_fn
|
|
)]
|
|
#![deny(anonymous_parameters, macro_use_extern_crate, pointer_structural_match)]
|
|
#![deny(missing_docs)]
|
|
#![allow(clippy::module_name_repetitions)]
|
|
|
|
#[cfg(doctest)]
|
|
doc_comment::doctest!("../../README.md");
|
|
|
|
mod client;
|
|
/// A pool of clients, to handle concurrent checks
|
|
pub mod collector;
|
|
mod helpers;
|
|
mod quirks;
|
|
mod types;
|
|
|
|
/// Functionality to extract URIs from inputs
|
|
pub mod extract;
|
|
|
|
/// Filters are a way to define behavior when encountering
|
|
/// URIs that need to be treated differently, such as
|
|
/// local IPs or e-mail addresses
|
|
pub mod filter;
|
|
|
|
#[cfg(test)]
|
|
#[macro_use]
|
|
pub mod test_utils;
|
|
|
|
#[cfg(test)]
|
|
use doc_comment as _; // required for doctest
|
|
use openssl_sys as _; // required for vendored-openssl feature
|
|
use ring as _; // required for apple silicon
|
|
|
|
#[doc(inline)]
|
|
pub use crate::{
|
|
// Constants get exposed so that the CLI can use the same defaults as the library
|
|
client::{
|
|
check, Client, ClientBuilder, DEFAULT_MAX_REDIRECTS, DEFAULT_MAX_RETRIES,
|
|
DEFAULT_RETRY_WAIT_TIME, DEFAULT_TIMEOUT, DEFAULT_USER_AGENT,
|
|
},
|
|
collector::Collector,
|
|
filter::{Excludes, Filter, Includes},
|
|
types::{
|
|
Base, CacheStatus, ErrorKind, FileType, Input, InputContent, InputSource, Request,
|
|
Response, ResponseBody, Result, Status, Uri,
|
|
},
|
|
};
|