Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
66 commits
Select commit Hold shift + click to select a range
f7488dd
stash
katrinafyi Oct 4, 2025
a9fe9ad
stash very broken
katrinafyi Oct 4, 2025
cef997e
Revert "stash very broken"
katrinafyi Oct 4, 2025
25f130b
Revert "stash"
katrinafyi Oct 4, 2025
d272a2b
feat: add CreateRequestItem error kind
katrinafyi Oct 4, 2025
f5fd8df
wrap
katrinafyi Oct 4, 2025
e4c5482
smuggle request errors through CreateRequestItem
katrinafyi Oct 4, 2025
963b276
stash Result with RawUri
katrinafyi Oct 4, 2025
9461325
Revert "stash Result with RawUri"
katrinafyi Oct 4, 2025
c1bd7ca
add help
katrinafyi Oct 4, 2025
65afcdd
add CollectResult to be less dubious
katrinafyi Oct 4, 2025
891255d
fix lints
katrinafyi Oct 4, 2025
ff87745
touch
katrinafyi Oct 4, 2025
024772a
introduce separate RequestError type. but...
katrinafyi Oct 5, 2025
3ee280e
add Status::RequestError
katrinafyi Oct 5, 2025
1ad2020
mark as error
katrinafyi Oct 5, 2025
25d32ce
remove ErrorKind::CreateRequestItem case
katrinafyi Oct 5, 2025
c7536d1
blah
katrinafyi Oct 5, 2025
d10190a
uncomment
katrinafyi Oct 5, 2025
4f74a77
restore old panic behaviour for input-source errors
katrinafyi Oct 5, 2025
3bca6c8
docs
katrinafyi Oct 5, 2025
49c550e
remove unused imports
katrinafyi Oct 5, 2025
6a007c2
fix example
katrinafyi Oct 7, 2025
d7ebbc0
clippy. includes boxing errorkind because it's big
katrinafyi Oct 7, 2025
17fad2c
propagate input loading errors too
katrinafyi Oct 7, 2025
976904a
handle is no longer fallible. add helper function
katrinafyi Oct 7, 2025
f0eda83
Delete clippy.toml
katrinafyi Oct 9, 2025
704ad98
Revert "Delete clippy.toml"
katrinafyi Oct 9, 2025
e5152cc
explain ignore-interior-mutability
katrinafyi Oct 9, 2025
6c959f3
Merge remote-tracking branch 'upstream/master' into propagate-early-e…
katrinafyi Oct 23, 2025
eef8b78
fix compilation
katrinafyi Oct 23, 2025
1a1b5df
review: add new error case for user-provided input failures, but
katrinafyi Oct 23, 2025
f331dbe
lint
katrinafyi Oct 23, 2025
5716ee9
move UserInputContent case into fn handle
katrinafyi Oct 24, 2025
300e368
try fix lint. help welcome. i can't compile this for some reason
katrinafyi Oct 24, 2025
e22f13c
add early checking for file and dir permissions (and fmt πŸ™Š)
katrinafyi Oct 24, 2025
5cc0c1b
lint
katrinafyi Oct 24, 2025
45906e8
use DirTraversal error for dir failures
katrinafyi Oct 24, 2025
2397577
update tests, including adjusting existing
katrinafyi Oct 24, 2025
802427b
remove "Skip relative URLs" from readme feature table
katrinafyi Oct 24, 2025
fe04a7c
Merge remote-tracking branch 'upstream/master' into propagate-early-e…
katrinafyi Nov 12, 2025
c594f6b
lint;
katrinafyi Nov 12, 2025
048edd6
fix invalid glob test
katrinafyi Nov 12, 2025
df91d1e
Preprocessor PathBuf
katrinafyi Nov 13, 2025
347a030
Revert "Preprocessor PathBuf"
katrinafyi Nov 13, 2025
33141c9
review comments aside from struct variant
katrinafyi Nov 13, 2025
012fd68
lint
katrinafyi Nov 13, 2025
8c34cf4
capitalise paragraph comments
katrinafyi Nov 13, 2025
e066600
comment for internal function
katrinafyi Nov 13, 2025
918e216
add light test case test_create_request_from_relative_file_path_errors
katrinafyi Nov 13, 2025
acfa23c
comment2
katrinafyi Nov 13, 2025
759b691
RequestBatch
katrinafyi Nov 16, 2025
bbbd94b
Revert "RequestBatch"
katrinafyi Nov 16, 2025
b7bb174
use Vec<Result<..>>
katrinafyi Nov 16, 2025
438a2d3
add LycheeResult to disambiguate from std Result
katrinafyi Nov 16, 2025
50e91d1
manually deduplicate valid requests but not errors.
katrinafyi Nov 16, 2025
8a6bc3f
change preprocessor tests to expect link checking errors
katrinafyi Nov 16, 2025
9a34dac
clippy
katrinafyi Nov 16, 2025
64be9a3
Merge remote-tracking branch 'upstream/master' into propagate-early-e…
katrinafyi Nov 16, 2025
6db8db4
merge main_command removal
katrinafyi Nov 16, 2025
25b1290
change to `error:` and add into_response helper function
katrinafyi Nov 16, 2025
70f793b
move request_error into separate file.
katrinafyi Nov 16, 2025
a6ba2a1
revert
katrinafyi Nov 16, 2025
ec943db
remove box (thanks to Thomas Zahner)
katrinafyi Nov 17, 2025
fdbf533
use lazylock
katrinafyi Nov 17, 2025
5aff2e6
inline errs_iter and reqs_iter with parentheses
katrinafyi Nov 17, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
add LycheeResult to disambiguate from std Result
  • Loading branch information
katrinafyi committed Nov 16, 2025
commit 438a2d3a7d4dfc5280993c546edd91288a41c51b
5 changes: 2 additions & 3 deletions lychee-bin/src/commands/dump.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ use log::error;
use log::warn;
use lychee_lib::Request;
use lychee_lib::RequestError;
use lychee_lib::Result;
use std::fs;
use std::io::{self, Write};
use tokio_stream::StreamExt;
Expand All @@ -13,9 +12,9 @@ use crate::verbosity::Verbosity;
use super::CommandParams;

/// Dump all detected links to stdout without checking them
pub(crate) async fn dump<S>(params: CommandParams<S>) -> Result<ExitCode>
pub(crate) async fn dump<S>(params: CommandParams<S>) -> lychee_lib::Result<ExitCode>
where
S: futures::Stream<Item = std::result::Result<Request, RequestError>>,
S: futures::Stream<Item = Result<Request, RequestError>>,
{
let requests = params.requests;
tokio::pin!(requests);
Expand Down
7 changes: 2 additions & 5 deletions lychee-bin/src/commands/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,10 @@ use std::sync::Arc;
use crate::cache::Cache;
use crate::options::Config;
use lychee_lib::RequestError;
use lychee_lib::Result;
use lychee_lib::{Client, Request};

/// Parameters passed to every command
pub(crate) struct CommandParams<
S: futures::Stream<Item = std::result::Result<Request, RequestError>>,
> {
pub(crate) struct CommandParams<S: futures::Stream<Item = Result<Request, RequestError>>> {
pub(crate) client: Client,
pub(crate) cache: Arc<Cache>,
pub(crate) requests: S,
Expand All @@ -33,7 +30,7 @@ pub(crate) struct CommandParams<
/// # Errors
///
/// Returns an error if the output file cannot be opened.
fn create_writer(output: Option<PathBuf>) -> Result<Box<dyn Write>> {
fn create_writer(output: Option<PathBuf>) -> lychee_lib::Result<Box<dyn Write>> {
Ok(match output {
Some(path) => Box::new(fs::OpenOptions::new().append(true).open(path)?),
None => Box::new(io::stdout().lock()),
Expand Down
24 changes: 12 additions & 12 deletions lychee-lib/src/collector.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ use crate::filter::PathExcludes;

use crate::types::resolver::UrlContentResolver;
use crate::{
Base, Input, Request, RequestError, Result, basic_auth::BasicAuthExtractor, extract::Extractor,
types::FileExtensions, types::uri::raw::RawUri, utils::request,
Base, Input, LycheeResult, Request, RequestError, basic_auth::BasicAuthExtractor,
extract::Extractor, types::FileExtensions, types::uri::raw::RawUri, utils::request,
};
use futures::TryStreamExt;
use futures::{
Expand Down Expand Up @@ -72,7 +72,7 @@ impl Collector {
///
/// Returns an `Err` if the `root_dir` is not an absolute path
/// or if the reqwest `Client` fails to build
pub fn new(root_dir: Option<PathBuf>, base: Option<Base>) -> Result<Self> {
pub fn new(root_dir: Option<PathBuf>, base: Option<Base>) -> LycheeResult<Self> {
if let Some(root_dir) = &root_dir
&& root_dir.is_relative()
{
Expand Down Expand Up @@ -183,7 +183,7 @@ impl Collector {
pub fn collect_links(
self,
inputs: HashSet<Input>,
) -> impl Stream<Item = std::result::Result<Request, RequestError>> {
) -> impl Stream<Item = Result<Request, RequestError>> {
self.collect_links_from_file_types(inputs, crate::types::FileType::default_extensions())
}

Expand All @@ -198,7 +198,7 @@ impl Collector {
self,
inputs: HashSet<Input>,
extensions: FileExtensions,
) -> impl Stream<Item = std::result::Result<Request, RequestError>> {
) -> impl Stream<Item = Result<Request, RequestError>> {
let skip_missing_inputs = self.skip_missing_inputs;
let skip_hidden = self.skip_hidden;
let skip_ignored = self.skip_ignored;
Expand Down Expand Up @@ -258,7 +258,7 @@ impl Collector {
base.as_ref(),
basic_auth_extractor.as_ref(),
);
std::result::Result::Ok(stream::iter(requests))
Result::Ok(stream::iter(requests))
}
})
.try_flatten()
Expand All @@ -276,7 +276,7 @@ mod tests {

use super::*;
use crate::{
Result, Uri,
LycheeResult, Uri,
filter::PathExcludes,
types::{FileType, Input, InputSource},
};
Expand All @@ -286,7 +286,7 @@ mod tests {
inputs: HashSet<Input>,
root_dir: Option<PathBuf>,
base: Option<Base>,
) -> Result<HashSet<Uri>> {
) -> LycheeResult<HashSet<Uri>> {
let responses = Collector::new(root_dir, base)?.collect_links(inputs);
Ok(responses.map(|r| r.unwrap().uri).collect().await)
}
Expand All @@ -300,7 +300,7 @@ mod tests {
root_dir: Option<PathBuf>,
base: Option<Base>,
extensions: FileExtensions,
) -> Result<HashSet<Uri>> {
) -> LycheeResult<HashSet<Uri>> {
let responses = Collector::new(root_dir, base)?
.include_verbatim(true)
.collect_links_from_file_types(inputs, extensions);
Expand All @@ -314,7 +314,7 @@ mod tests {
const TEST_GLOB_2_MAIL: &str = "test@glob-2.io";

#[tokio::test]
async fn test_file_without_extension_is_plaintext() -> Result<()> {
async fn test_file_without_extension_is_plaintext() -> LycheeResult<()> {
let temp_dir = tempfile::tempdir().unwrap();
// Treat as plaintext file (no extension)
let file_path = temp_dir.path().join("README");
Expand All @@ -339,7 +339,7 @@ mod tests {
}

#[tokio::test]
async fn test_url_without_extension_is_html() -> Result<()> {
async fn test_url_without_extension_is_html() -> LycheeResult<()> {
let input = Input::new("https://example.com/", None, true)?;
let contents: Vec<_> = input
.get_contents(
Expand All @@ -360,7 +360,7 @@ mod tests {
}

#[tokio::test]
async fn test_collect_links() -> Result<()> {
async fn test_collect_links() -> LycheeResult<()> {
let temp_dir = tempfile::tempdir().unwrap();
let temp_dir_path = temp_dir.path();

Expand Down
6 changes: 3 additions & 3 deletions lychee-lib/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -95,8 +95,8 @@ pub use crate::{
types::{
AcceptRange, AcceptRangeError, Base, BasicAuthCredentials, BasicAuthSelector, CacheStatus,
CookieJar, ErrorKind, FileExtensions, FileType, Input, InputContent, InputResolver,
InputSource, Preprocessor, Redirects, Request, RequestError, ResolvedInputSource, Response,
ResponseBody, Result, Status, StatusCodeExcluder, StatusCodeSelector, uri::raw::RawUri,
uri::valid::Uri,
InputSource, LycheeResult, Preprocessor, Redirects, Request, RequestError,
ResolvedInputSource, Response, ResponseBody, Result, Status, StatusCodeExcluder,
StatusCodeSelector, uri::raw::RawUri, uri::valid::Uri,
},
};
21 changes: 12 additions & 9 deletions lychee-lib/src/types/input/input.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use super::source::{InputSource, ResolvedInputSource};
use crate::Preprocessor;
use crate::filter::PathExcludes;
use crate::types::{FileType, RequestError, file::FileExtensions, resolver::UrlContentResolver};
use crate::{ErrorKind, Result};
use crate::{ErrorKind, LycheeResult};
use async_stream::try_stream;
use futures::stream::{Stream, StreamExt};
use std::path::{Path, PathBuf};
Expand Down Expand Up @@ -42,7 +42,7 @@ impl Input {
input: &str,
file_type_hint: Option<FileType>,
glob_ignore_case: bool,
) -> Result<Self> {
) -> LycheeResult<Self> {
let source = InputSource::new(input, glob_ignore_case)?;
Ok(Self {
source,
Expand All @@ -57,7 +57,7 @@ impl Input {
/// Returns an error if:
/// - the input does not exist (i.e. the path is invalid)
/// - the input cannot be parsed as a URL
pub fn from_value(value: &str) -> Result<Self> {
pub fn from_value(value: &str) -> LycheeResult<Self> {
Self::new(value, None, false)
}

Expand Down Expand Up @@ -95,7 +95,7 @@ impl Input {
resolver: UrlContentResolver,
excluded_paths: PathExcludes,
preprocessor: Option<Preprocessor>,
) -> impl Stream<Item = std::result::Result<InputContent, RequestError>> {
) -> impl Stream<Item = Result<InputContent, RequestError>> {
try_stream! {
let source = self.source.clone();

Expand Down Expand Up @@ -223,7 +223,7 @@ impl Input {
skip_hidden: bool,
skip_ignored: bool,
excluded_paths: &PathExcludes,
) -> impl Stream<Item = Result<String>> {
) -> impl Stream<Item = LycheeResult<String>> {
InputResolver::resolve(
&self,
file_extensions,
Expand All @@ -250,7 +250,7 @@ impl Input {
pub async fn path_content<P: Into<PathBuf> + AsRef<Path> + Clone>(
path: P,
preprocessor: Option<&Preprocessor>,
) -> Result<InputContent> {
) -> LycheeResult<InputContent> {
let path = path.into();
let content = Self::get_content(&path, preprocessor).await?;

Expand All @@ -266,7 +266,7 @@ impl Input {
/// # Errors
///
/// Returns an error if stdin cannot be read
pub async fn stdin_content(file_type_hint: Option<FileType>) -> Result<InputContent> {
pub async fn stdin_content(file_type_hint: Option<FileType>) -> LycheeResult<InputContent> {
let mut content = String::new();
let mut stdin = stdin();
stdin.read_to_string(&mut content).await?;
Expand All @@ -288,7 +288,10 @@ impl Input {

/// Get content of file.
/// Get preprocessed file content if [`Preprocessor`] is [`Some`]
async fn get_content(path: &PathBuf, preprocessor: Option<&Preprocessor>) -> Result<String> {
async fn get_content(
path: &PathBuf,
preprocessor: Option<&Preprocessor>,
) -> LycheeResult<String> {
if let Some(pre) = preprocessor {
pre.process(path)
} else {
Expand All @@ -302,7 +305,7 @@ impl Input {
impl TryFrom<&str> for Input {
type Error = crate::ErrorKind;

fn try_from(value: &str) -> std::result::Result<Self, Self::Error> {
fn try_from(value: &str) -> Result<Self, Self::Error> {
Self::from_value(value)
}
}
Expand Down
3 changes: 3 additions & 0 deletions lychee-lib/src/types/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,3 +35,6 @@ pub use status_code::*;

/// The lychee `Result` type
pub type Result<T> = std::result::Result<T, crate::ErrorKind>;

/// The lychee `Result` type, aliased to avoid conflicting with std::result::Result.
pub type LycheeResult<T> = Result<T>;
16 changes: 8 additions & 8 deletions lychee-lib/src/utils/request.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use reqwest::Url;
use std::path::{Path, PathBuf};

use crate::{
Base, BasicAuthCredentials, ErrorKind, Request, RequestError, Result, Uri,
Base, BasicAuthCredentials, ErrorKind, LycheeResult, Request, RequestError, Uri,
basic_auth::BasicAuthExtractor,
types::{ResolvedInputSource, uri::raw::RawUri},
utils::{path, url},
Expand All @@ -24,7 +24,7 @@ fn create_request(
root_dir: Option<&PathBuf>,
base: Option<&Base>,
extractor: Option<&BasicAuthExtractor>,
) -> Result<Request> {
) -> LycheeResult<Request> {
let uri = try_parse_into_uri(raw_uri, source, root_dir, base)?;
let source = source.clone();
let element = raw_uri.element.clone();
Expand All @@ -50,7 +50,7 @@ fn try_parse_into_uri(
source: &ResolvedInputSource,
root_dir: Option<&PathBuf>,
base: Option<&Base>,
) -> Result<Uri> {
) -> LycheeResult<Uri> {
let text = prepend_root_dir_if_absolute_local_link(&raw_uri.text, root_dir);
let uri = match Uri::try_from(raw_uri.clone()) {
Ok(uri) => uri,
Expand Down Expand Up @@ -86,7 +86,7 @@ fn create_uri_from_file_path(
file_path: &Path,
link_text: &str,
ignore_absolute_local_links: bool,
) -> Result<Uri> {
) -> LycheeResult<Uri> {
let target_path = if is_anchor(link_text) {
// For anchors, we need to append the anchor to the file name.
let file_name = file_path
Expand Down Expand Up @@ -119,7 +119,7 @@ pub(crate) fn create(
root_dir: Option<&PathBuf>,
base: Option<&Base>,
extractor: Option<&BasicAuthExtractor>,
) -> Vec<std::result::Result<Request, RequestError>> {
) -> Vec<Result<Request, RequestError>> {
let base = base.cloned().or_else(|| Base::from_source(source));

uris.into_iter()
Expand All @@ -146,7 +146,7 @@ fn resolve_and_create_url(
src_path: &Path,
dest_path: &str,
ignore_absolute_local_links: bool,
) -> Result<Url> {
) -> LycheeResult<Url> {
let (dest_path, fragment) = url::remove_get_params_and_separate_fragment(dest_path);

// Decode the destination path to avoid double-encoding
Expand Down Expand Up @@ -191,7 +191,7 @@ mod tests {
/// Create requests from the given raw URIs and returns requests that were
/// constructed successfully, silently ignoring link parsing errors.
///
/// This reduces the Result handling which is needed in test cases. Test
/// This reduces the LycheeResult handling which is needed in test cases. Test
/// cases can still detect the unexpected appearance of errors by the
/// length being different.
fn create_ok_only(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I understand that this is an internal function for testing only, but can we still add a comment about what it does and why?

Expand All @@ -203,7 +203,7 @@ mod tests {
) -> HashSet<Request> {
create(uris, source, root_dir, base, extractor)
.into_iter()
.filter_map(std::result::Result::ok)
.filter_map(Result::ok)
.collect()
}

Expand Down
Loading