pub struct Input {
pub source: InputSource,
pub file_type_hint: Option<FileType>,
}
Expand description
Lychee Input with optional file hint for parsing
Fields§
§source: InputSource
Origin of input
file_type_hint: Option<FileType>
Hint to indicate which extractor to use
Implementations§
Source§impl Input
impl Input
Sourcepub fn new(
input: &str,
file_type_hint: Option<FileType>,
glob_ignore_case: bool,
) -> Result<Self>
pub fn new( input: &str, file_type_hint: Option<FileType>, glob_ignore_case: bool, ) -> Result<Self>
Construct a new Input
source. In case the input is a glob
pattern,
glob_ignore_case
decides whether matching files against the glob
is
case-insensitive or not
§Errors
Returns an error if the input does not exist (i.e. invalid path) and the input cannot be parsed as a URL.
Sourcepub fn from_value(value: &str) -> Result<Self>
pub fn from_value(value: &str) -> Result<Self>
Convenience constructor with sane defaults
§Errors
Returns an error if the input does not exist (i.e. invalid path) and the input cannot be parsed as a URL.
Sourcepub const fn from_input_source(source: InputSource) -> Self
pub const fn from_input_source(source: InputSource) -> Self
Convenience constructor
Sourcepub fn get_input_sources<'a>(
&'a self,
file_extensions: FileExtensions,
skip_hidden: bool,
skip_gitignored: bool,
excluded_paths: &'a PathExcludes,
) -> impl Stream<Item = Result<InputSource>> + 'a
pub fn get_input_sources<'a>( &'a self, file_extensions: FileExtensions, skip_hidden: bool, skip_gitignored: bool, excluded_paths: &'a PathExcludes, ) -> impl Stream<Item = Result<InputSource>> + 'a
Get all input sources for content processing.
This method returns a stream of input sources for the given input, taking into account the matching file extensions and respecting exclusions.
This can be used for retrieving all inputs which lychee would check for links.
§Returns
Returns a stream of Result<InputSource>
for all matching input sources.
§Errors
Will return errors for file system operations or glob pattern issues
Sourcepub fn get_contents(
self,
skip_missing: bool,
skip_hidden: bool,
skip_gitignored: bool,
file_extensions: FileExtensions,
resolver: UrlContentResolver,
excluded_paths: PathExcludes,
) -> impl Stream<Item = Result<InputContent>>
pub fn get_contents( self, skip_missing: bool, skip_hidden: bool, skip_gitignored: bool, file_extensions: FileExtensions, resolver: UrlContentResolver, excluded_paths: PathExcludes, ) -> impl Stream<Item = Result<InputContent>>
Retrieve the contents from the input
If the input is a path, only search through files that match the given file extensions.
§Errors
Returns an error if the contents can not be retrieved because of an underlying I/O error (e.g. an error while making a network request or retrieving the contents from the file system)
Sourcepub fn get_sources(
self,
file_extensions: FileExtensions,
skip_hidden: bool,
skip_gitignored: bool,
excluded_paths: &PathExcludes,
) -> impl Stream<Item = Result<String>>
pub fn get_sources( self, file_extensions: FileExtensions, skip_hidden: bool, skip_gitignored: bool, excluded_paths: &PathExcludes, ) -> impl Stream<Item = Result<String>>
Retrieve all sources from this input. The output depends on the type of input:
- Remote URLs are returned as is, in their full form
- Filepath Glob Patterns are expanded and each matched entry is returned
- Absolute or relative filepaths are returned as is
- All other input types are not returned
§Errors
Returns an error if the globbing fails with the expanded pattern.
Sourcepub async fn path_content<P: Into<PathBuf> + AsRef<Path> + Clone>(
path: P,
) -> Result<InputContent>
pub async fn path_content<P: Into<PathBuf> + AsRef<Path> + Clone>( path: P, ) -> Result<InputContent>
Trait Implementations§
impl Eq for Input
impl StructuralPartialEq for Input
Auto Trait Implementations§
impl Freeze for Input
impl RefUnwindSafe for Input
impl Send for Input
impl Sync for Input
impl Unpin for Input
impl UnwindSafe for Input
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<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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 more