Struct lychee_lib::Input
source · pub struct Input {
pub source: InputSource,
pub file_type_hint: Option<FileType>,
pub excluded_paths: Option<Vec<PathBuf>>,
}
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
excluded_paths: Option<Vec<PathBuf>>
Excluded paths that will be skipped when reading content
Implementations§
source§impl Input
impl Input
sourcepub fn new(
value: &str,
file_type_hint: Option<FileType>,
glob_ignore_case: bool,
excluded_paths: Option<Vec<PathBuf>>
) -> Result<Self>
pub fn new( value: &str, file_type_hint: Option<FileType>, glob_ignore_case: bool, excluded_paths: Option<Vec<PathBuf>> ) -> 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 get_contents(
self,
skip_missing: bool
) -> impl Stream<Item = Result<InputContent>>
pub fn get_contents( self, skip_missing: bool ) -> impl Stream<Item = Result<InputContent>>
Retrieve the contents from the input
§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) -> impl Stream<Item = Result<String>>
pub fn get_sources(self) -> 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§
source§impl PartialEq for Input
impl PartialEq for Input
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<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
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<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