Skip to main content

MultiSourceOptions

Struct MultiSourceOptions 

Source
pub struct MultiSourceOptions {
    pub resolver: SharedResolver,
    pub path: String,
    pub markchar: String,
    pub processor: IndexMap<String, ProcessorEntry>,
    pub implicit_ext: Vec<String>,
    pub preload: Option<PreloadOptions>,
    pub fs: Option<SharedFs>,
    pub deps: Option<Arc<Mutex<DependencyMap>>>,
    pub max_depth: usize,
}
Expand description

Configuration for the plugin.

Fields§

§resolver: SharedResolver

Resolves a reference to a source.

§path: String

The base path references resolve against at the top level.

§markchar: String

The character that starts a reference.

§processor: IndexMap<String, ProcessorEntry>

Per-kind processors. The empty kind is the fallback.

§implicit_ext: Vec<String>

Extensions tried for a reference with none, in order.

§preload: Option<PreloadOptions>

A declarative record of a folder preload. As in TypeScript and Go, the plugin does not consume it: call preload_files and hand the result to FileResolver::with_preload.

§fs: Option<SharedFs>

The filesystem the file and pkg resolvers read, when they carry none of their own. None is the real filesystem.

This is the Rust spelling of the TypeScript ctx.meta.fs injection point and of Go’s MultiSourceOptions.FS.

§deps: Option<Arc<Mutex<DependencyMap>>>

Where to record the tar to src dependency tree, when the caller wants one.

§max_depth: usize

How deep a chain of sources may nest. See DEFAULT_MAX_DEPTH.

Implementations§

Source§

impl MultiSourceOptions

Source

pub fn new(resolver: impl Resolver + 'static) -> Self

Options resolving through resolver, everything else default.

Source

pub fn with_resolver(self, resolver: SharedResolver) -> Self

Options resolving through an already shared resolver.

Source

pub fn with_path(self, path: impl Into<String>) -> Self

Set the base path references resolve against.

Source

pub fn with_markchar(self, markchar: impl Into<String>) -> Self

Set the directive character.

Source

pub fn with_processor( self, kind: impl Into<String>, processor: impl Processor + 'static, ) -> Self

Register a processor for one kind, replacing any entry for it.

Source

pub fn with_processor_alias( self, kind: impl Into<String>, target: impl Into<String>, ) -> Self

Point one kind at another kind’s processor.

Source

pub fn with_processors( self, processors: IndexMap<String, ProcessorEntry>, ) -> Self

Replace the whole processor table.

Source

pub fn with_implicit_ext<I, S>(self, extensions: I) -> Self
where I: IntoIterator<Item = S>, S: AsRef<str>,

Replace the implicit extension list. A missing leading dot is added, as the TypeScript plugin does when it installs.

Source

pub fn with_preload(self, preload: PreloadOptions) -> Self

Record a preload configuration. The plugin does not act on it.

Source

pub fn with_fs(self, filesystem: impl SourceFs + 'static) -> Self

Set the filesystem the file and pkg resolvers read.

Source

pub fn with_shared_fs(self, filesystem: SharedFs) -> Self

Set the filesystem from an already shared handle.

Source

pub fn with_deps(self, deps: Arc<Mutex<DependencyMap>>) -> Self

Collect the dependency tree into deps as the parse runs.

Source

pub fn with_max_depth(self, max_depth: usize) -> Self

Set how deep a chain of sources may nest.

Source

pub fn processor_for(&self, kind: &str) -> Option<Arc<dyn Processor>>

The processor for kind, resolving one level of aliasing and falling back to the NONE entry, as getProcessor does.

Trait Implementations§

Source§

impl Clone for MultiSourceOptions

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Debug for MultiSourceOptions

Source§

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

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

impl Default for MultiSourceOptions

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

§

impl !RefUnwindSafe for MultiSourceOptions

§

impl !UnwindSafe for MultiSourceOptions

§

impl Forget for MultiSourceOptions

§

impl Freeze for MultiSourceOptions

§

impl Move for MultiSourceOptions

§

impl Send for MultiSourceOptions
where Arc<dyn Resolver>: Send, RawVecInner: Send, RawTable<usize>: Send, Arc<dyn Processor>: Send, Arc<dyn SourceFs>: Send, Arc<Mutex<BTreeMap<String, BTreeMap<String, Dependency>>>>: Send,

§

impl Sync for MultiSourceOptions
where Arc<dyn Resolver>: Sync, RawVecInner: Sync, RawTable<usize>: Sync, Arc<dyn Processor>: Sync, Arc<dyn SourceFs>: Sync, Arc<Mutex<BTreeMap<String, BTreeMap<String, Dependency>>>>: Sync,

§

impl Unpin for MultiSourceOptions

§

impl UnsafeUnpin for MultiSourceOptions

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<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> 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 = !

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

fn try_from(value: U) -> Result<T, !>

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.