pub struct Input {
pub source: InputSource,
pub file_type_hint: Option<FileType>,
}Expand description
Lychee Input with optional file hint for parsing
Fields§
§source: InputSourceOrigin of input
file_type_hint: Option<FileType>Hint to indicate which extractor to use
If this is not provided, the extractor will be guessed from the input (e.g. file extension or URL path)
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. the path is invalid)
- 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 default settings
§Errors
Returns an error if:
- the input does not exist (i.e. the path is invalid)
- 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
Create an Input from an existing InputSource
The file type will be determined later when processing the input.
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 glob pattern is invalid or expansion encounters I/O errors
- Directory traversal fails, including:
- Permission denied when accessing directories or files
- I/O errors while reading directory contents
- Filesystem errors (disk errors, network filesystem issues, etc.)
- Invalid file paths or symbolic link resolution failures
- Errors when reading or evaluating
.gitignoreor.ignorefiles - Errors occur during file extension or path exclusion evaluation
Note: Individual glob match failures are logged to stderr but don’t terminate the stream. However, directory traversal errors will stop processing and return the error immediately.
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>
Sourcepub async fn stdin_content(
file_type_hint: Option<FileType>,
) -> Result<InputContent>
pub async fn stdin_content( file_type_hint: Option<FileType>, ) -> Result<InputContent>
Sourcepub fn string_content(s: &str, file_type_hint: Option<FileType>) -> InputContent
pub fn string_content(s: &str, file_type_hint: Option<FileType>) -> InputContent
Create InputContent from a string.
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