Skip to main content

Project

Struct Project 

Source
pub struct Project {
    pub root: PathBuf,
    pub manifest: Manifest,
    pub entry: Option<PathBuf>,
}
Expand description

A project on disk: its manifest, its entry program if it has one, and its directories.

Loading reads no source. Project::shape parses the entry; commands that only need the program set (check, test, fmt) never pay for — or fail on — that parse.

Fields§

§root: PathBuf

The directory holding Largo.toml.

§manifest: Manifest

The parsed manifest.

§entry: Option<PathBuf>

The entry program, or None for a site that has none.

Implementations§

Source§

impl Project

Source

pub fn load(root: &Path) -> Result<Project, CliError>

Load the project rooted at root.

Source

pub fn pages_dir(&self) -> PathBuf

pages/ — one program per .lg file, each served at its own URL.

Source

pub fn static_dir(&self) -> PathBuf

static/ — files served verbatim at root-relative paths.

Source

pub fn has_site(&self) -> bool

Whether the project has a site: a pages/ or a static/ directory.

Source

pub fn shape(&self) -> Result<ProjectShape, CliError>

The shape: ProjectShape::from_facts over Project::has_site and whether the entry’s assembled program contains a Serve statement.

An entry that does not assemble or does not parse is an error here rather than a guess: a full-stack site whose backend has a syntax error must not quietly become a site without one. The error is the same rendered diagnostic largo check prints.

Source

pub fn require_entry(&self) -> Result<&Path, CliError>

The entry program, or the error that says this project is a site and has none — for the commands (run, emit, doc, …) that are about a program.

Source

pub fn shape_or_best_effort(&self) -> ProjectShape

The shape, but NEVER refusing over a parse error: Project::shape’s exact answer when the entry parses, and a shape decided from what can still be read — has_site() (a file- system fact, unaffected by any parse) and a LEXICAL (not grammatical) scan for a Serve statement — when it does not.

A watch-mode dev server exists to survive the author’s mistakes: starting largo serve --watch on a page mid-typo, or a save that breaks it, must still bind a port and show the located error, never refuse to start. Project::shape remains the STRICT form for every other command (check, build, test, fmt, doctor) — they want “and it currently parses” folded into the answer, and their own pipelines report the parse error at the right place regardless (plan_web_bundle’s own comment: “the compile step below reports that at its line, so it is not reported twice here”).

Trait Implementations§

Source§

impl Clone for Project

Source§

fn clone(&self) -> Project

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 Project

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

impl<T> Downcast for T
where T: Any,

§

fn into_any(self: Box<T>) -> Box<dyn Any>

Convert Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.
§

fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>

Convert Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be further downcast into Rc<ConcreteType> where ConcreteType implements Trait.
§

fn as_any(&self) -> &(dyn Any + 'static)

Convert &Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &Any’s vtable from &Trait’s.
§

fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)

Convert &mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &mut Any’s vtable from &mut Trait’s.
§

impl<T> DowncastSync for T
where T: Any + Send + Sync,

§

fn into_any_arc(self: Arc<T>) -> Arc<dyn Any + Send + Sync>

Convert Arc<Trait> (where Trait: Downcast) to Arc<Any>. Arc<Any> can then be further downcast into Arc<ConcreteType> where ConcreteType implements Trait.
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> 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.
§

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

§

fn vzip(self) -> V

§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,