pub struct LiveReloadServer { /* private fields */ }Expand description
Server-side live-reload state.
Caches HTML and head injections per route, diffs new HTML against the cache,
and produces LiveReloadEvent messages.
Transport-agnostic — callers are responsible for delivering events to clients.
Implementations§
Source§impl LiveReloadServer
impl LiveReloadServer
pub fn new() -> Self
Sourcepub fn cache_html(&mut self, route: &str, html: &str) -> Option<String>
pub fn cache_html(&mut self, route: &str, html: &str) -> Option<String>
Cache HTML for a route (call when serving). Returns previous HTML if any.
Sourcepub fn cache_head_injections(&mut self, route: &str, injections: &str) -> bool
pub fn cache_head_injections(&mut self, route: &str, injections: &str) -> bool
Cache head injections. Returns true if they changed.
Sourcepub fn diff_route(
&mut self,
route: &str,
new_html: &str,
) -> Option<LiveReloadEvent>
pub fn diff_route( &mut self, route: &str, new_html: &str, ) -> Option<LiveReloadEvent>
Diff new HTML against cache. Returns event to send, or None if unchanged.
Sourcepub fn diff_route_with_head(
&mut self,
route: &str,
new_html: &str,
head_injections: &str,
) -> Option<LiveReloadEvent>
pub fn diff_route_with_head( &mut self, route: &str, new_html: &str, head_injections: &str, ) -> Option<LiveReloadEvent>
Diff with head injection tracking combined.
If head injections changed, returns HeadChanged (requires full reload).
Otherwise diffs body HTML and returns Patches or None.
Sourcepub fn cached_routes(&self) -> Vec<String>
pub fn cached_routes(&self) -> Vec<String>
All cached route keys.
Sourcepub fn remove_route(&mut self, route: &str) -> bool
pub fn remove_route(&mut self, route: &str) -> bool
Remove a route from cache.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for LiveReloadServer
impl RefUnwindSafe for LiveReloadServer
impl Send for LiveReloadServer
impl Sync for LiveReloadServer
impl Unpin for LiveReloadServer
impl UnsafeUnpin for LiveReloadServer
impl UnwindSafe for LiveReloadServer
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