pub struct AppState {
pub project_root: PathBuf,
pub out_dir: PathBuf,
pub docs_dir: PathBuf,
pub base: String,
pub port: u16,
pub reload_tx: Sender<ReloadEvent>,
/* private fields */
}Expand description
Shared, cheaply-clonable state behind every handler. Clone bumps the
Arc/broadcast handle.
Fields§
§project_root: PathBuf§out_dir: PathBuf§docs_dir: PathBufCanonicalized docs/ dir — the write-guard root.
base: StringSite base path (e.g. /docs), normalized to a leading-slash, no-trailing-slash
form; empty when the site is served at the root. The built HTML prefixes every
asset/nav/wikilink URL with this, so the dev server must strip it off incoming
request paths before resolving them against out_dir.
port: u16The loopback port the server is bound to. Used by the Host-header
allowlist to defeat DNS-rebinding (see handlers::loopback_guard).
reload_tx: Sender<ReloadEvent>Implementations§
Source§impl AppState
impl AppState
Sourcepub fn new(
project_root: PathBuf,
out_dir: PathBuf,
docs_dir: PathBuf,
port: u16,
reload_tx: Sender<ReloadEvent>,
) -> Self
pub fn new( project_root: PathBuf, out_dir: PathBuf, docs_dir: PathBuf, port: u16, reload_tx: Sender<ReloadEvent>, ) -> Self
Construct an AppState. Initializes the self-write suppression clock.
Sourcepub fn with_engine(self, engine: DevState) -> Self
pub fn with_engine(self, engine: DevState) -> Self
Attach the incremental build engine. Builder-style so the new() call
sites (including tests) stay untouched. Only serve_async sets one.
Sourcepub fn with_base(self, base: &str) -> Self
pub fn with_base(self, base: &str) -> Self
Set the site base path, normalized to a leading-slash, no-trailing-slash
form (docs / /docs/ / docs/ all become /docs; empty stays empty).
Builder-style so the existing new() call sites stay untouched.
Sourcepub fn note_self_write(&self)
pub fn note_self_write(&self)
Record that the editor just wrote a doc on disk. The watcher will skip
the next change it sees within [SELF_WRITE_SUPPRESS] as a duplicate.
Sourcepub fn take_self_write_suppression(&self) -> bool
pub fn take_self_write_suppression(&self) -> bool
Whether a watcher event right now should be suppressed as the echo of a recent editor write. Consumes the marker so only one rebuild is skipped.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for AppState
impl RefUnwindSafe for AppState
impl Send for AppState
impl Sync for AppState
impl Unpin for AppState
impl UnsafeUnpin for AppState
impl UnwindSafe for AppState
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<A, B, T> HttpServerConnExec<A, B> for Twhere
B: Body,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more