Input

Struct Input 

Source
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

If this is not provided, the extractor will be guessed from the input (e.g. file extension or URL path)

Implementations§

Source§

impl Input

Source

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
Source

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
Source

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.

Source

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)

Source

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 .gitignore or .ignore files
  • 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.

Source

pub async fn path_content<P: Into<PathBuf> + AsRef<Path> + Clone>( path: P, ) -> Result<InputContent>

Get the content for a given path.

§Errors

Returns an error if the file cannot be read

Source

pub async fn stdin_content( file_type_hint: Option<FileType>, ) -> Result<InputContent>

Create InputContent from stdin.

§Errors

Returns an error if stdin cannot be read

Source

pub fn string_content(s: &str, file_type_hint: Option<FileType>) -> InputContent

Create InputContent from a string.

Trait Implementations§

Source§

impl Clone for Input

Source§

fn clone(&self) -> Input

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Input

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Hash for Input

Source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl PartialEq for Input

Source§

fn eq(&self, other: &Input) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl TryFrom<&str> for Input

Source§

type Error = ErrorKind

The type returned in the event of a conversion error.
Source§

fn try_from(value: &str) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl Eq for Input

Source§

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> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

impl<T> ErasedDestructor for T
where T: 'static,