Skip to main content

SourceFile

Struct SourceFile 

Source
pub struct SourceFile { /* private fields */ }

Implementations§

Source§

impl SourceFile

Source

pub fn load( abs_path: PathBuf, root_dir: &Path, root: SourceRoot, package: Option<&PackageName>, overlay: &Overlay, ) -> Result<SourceFile, SourceFileError>

Load a SourceFile from the file system.

root_dir is the directory the file was walked from and root says which of the package’s two source roots that is; a module’s name is its path under its own root, so the two roots are walked separately and each file is named relative to the one it came from.

package is the name of the package root_dir belongs to, and is what the rendered file name is prefixed with. It is Some whenever the file joins a database that holds more than one package’s files: a path relative to a package’s own src/ is not unique across a build — two packages may each hold a Size.zel — so without it a diagnostic cannot say which package it is about. None is for a database of exactly one package, where the prefix would be noise.

The text is overlay’s when it holds abs_path, and the file’s otherwise.

Source

pub fn file(&self) -> &SimpleFile<String, String>

Source

pub fn module_name(&self) -> Name

The module name this file’s path gives it: src/Js/Basics.zel is Js.Basics.

A module is otherwise called by the name its header declares, and nothing checks the two agree. This is the name a file whose header did not parse is known by.

Source

pub fn package_path(&self) -> String

Where this file sits in its package: the source root it was walked from and its path under that root, as src/Model.zel.

This is the half of the rendered name that belongs to the package rather than to the build, and it is what a diagnostic about the package’s own layout — two modules answering to one name — names each file by.

Trait Implementations§

Source§

impl Debug for SourceFile

Source§

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

Formats the value using the given formatter. Read more

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, 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.