pub struct AppState {
pub project_root: PathBuf,
pub out_dir: PathBuf,
pub docs_dir: PathBuf,
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.
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 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
Mutably borrows from an owned value. Read more
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>
Converts
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>
Converts
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