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: PathBufThe directory holding Largo.toml.
manifest: ManifestThe parsed manifest.
entry: Option<PathBuf>The entry program, or None for a site that has none.
Implementations§
Source§impl Project
impl Project
Sourcepub fn pages_dir(&self) -> PathBuf
pub fn pages_dir(&self) -> PathBuf
pages/ — one program per .lg file, each served at its own URL.
Sourcepub fn static_dir(&self) -> PathBuf
pub fn static_dir(&self) -> PathBuf
static/ — files served verbatim at root-relative paths.
Sourcepub fn has_site(&self) -> bool
pub fn has_site(&self) -> bool
Whether the project has a site: a pages/ or a static/ directory.
Sourcepub fn shape(&self) -> Result<ProjectShape, CliError>
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.
Sourcepub fn require_entry(&self) -> Result<&Path, CliError>
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.
Sourcepub fn shape_or_best_effort(&self) -> ProjectShape
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§
Auto Trait Implementations§
impl Freeze for Project
impl RefUnwindSafe for Project
impl Send for Project
impl Sync for Project
impl Unpin for Project
impl UnsafeUnpin for Project
impl UnwindSafe for Project
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
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>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
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)
fn as_any(&self) -> &(dyn Any + 'static)
&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)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.