rune/worker/
task.rs

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
use crate::alloc::path::PathBuf;
use crate::compile::{ItemId, ModId};
use crate::worker::{Import, WildcardImport};
use crate::SourceId;

/// A single task that can be fed to the worker.
pub(crate) enum Task {
    /// Load a file.
    LoadFile {
        /// The kind of loaded file.
        kind: LoadFileKind,
        /// The source id of the item being loaded.
        source_id: SourceId,
        /// The item of the file to load.
        mod_item: ModId,
        /// Unique item stack identifier.
        mod_item_id: ItemId,
    },
    /// Expand a single import.
    ExpandImport(Import),
    /// Deferred action, since it requires all modules to be loaded to be able
    /// to discover all modules.
    ExpandWildcardImport(WildcardImport),
}

/// The kind of the loaded module.
#[derive(Debug)]
pub(crate) enum LoadFileKind {
    /// A root file, which determined a URL root.
    Root,
    /// A loaded module, which inherits its root from the file it was loaded
    /// from.
    Module { root: Option<PathBuf> },
}