Directory

Struct Directory 

Source
pub struct Directory { /* private fields */ }
Expand description

A file source that reads files from a directory.

Will try to ignore files be default. See WalkBuilder for more information.

Implementations§

Source§

impl Directory

Source

pub fn new( path: impl AsRef<Path>, buf_size: usize, ) -> Result<Self, Box<dyn ErrorTrait>>

Creates a new directory file source.

Set buf_size to a reasonable value for your system. You most likely would want to set this to the same value as read_limit when building a Gengo instance with a Builder.

Trait Implementations§

Source§

impl<'files> FileSource<'files> for Directory

Source§

type Entry = PathBuf

Source§

type Filepath = PathBuf

Source§

type Contents = Vec<u8>

Source§

type State = ()

Sometimes it’s necessary to share a state between iterations to reduce expensive commands.
Source§

type Iter = Iter

Source§

fn entries(&'files self) -> Result<Self::Iter, Box<dyn ErrorTrait>>

Returns an iterator over the entries use to get filenames and contents.
Source§

fn filepath( &'files self, entry: &Self::Entry, _state: &mut Self::State, ) -> Result<Self::Filepath, Box<dyn ErrorTrait>>

Gets a filename from an entry.
Source§

fn contents( &'files self, entry: &Self::Entry, _state: &mut Self::State, ) -> Result<Self::Contents, Box<dyn ErrorTrait>>

Gets file contents from an entry.
Source§

fn state(&'files self) -> Result<Self::State, Box<dyn ErrorTrait>>

Gets a state that can be shared between iterations.
Source§

fn overrides( &self, path: impl AsRef<Path>, state: &mut Self::State, ) -> Overrides

Provides combined overrides for the file.
Source§

fn language_override( &self, _path: impl AsRef<Path>, _state: &mut Self::State, ) -> Option<Language>

Provides an optional override for the detected language.
Source§

fn is_documentation_override( &self, _path: impl AsRef<Path>, _state: &mut Self::State, ) -> Option<bool>

Provides an optional override for documentation file detection.
Source§

fn is_generated_override( &self, _path: impl AsRef<Path>, _state: &mut Self::State, ) -> Option<bool>

Provides an optional override for generated file detection.
Source§

fn is_vendored_override( &self, _path: impl AsRef<Path>, _state: &mut Self::State, ) -> Option<bool>

Provides an optional override for vendored file detection.
Source§

fn is_detectable_override( &self, _path: impl AsRef<Path>, _state: &mut Self::State, ) -> Option<bool>

Provides an optional override for if the file is detectable.

Auto Trait Implementations§

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> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

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> 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> Same for T

Source§

type Output = T

Should always be Self
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.