Skip to main content

HmrHub

Struct HmrHub 

Source
pub struct HmrHub { /* private fields */ }
Expand description

Shared concurrent state coordinating SSE reload notifications, OTA bundles, and server shutdown.

Implementations§

Source§

impl HmrHub

Thread-safe HMR broadcast and OTA bundle coordination for HmrHub.

Source

pub fn new(initial_ota: OtaBundleState) -> Self

Creates a new HmrHub initialized at revision 1 with initial_ota.

§Arguments
  • OtaBundleState - Initial signed Dynamic WASM OTA artifact.
§Returns
  • Self - Initialized hub ready for concurrent access.
Source

pub fn revision(&self) -> u64

Returns the current monotonic rebuild revision counter.

§Arguments
  • &Self - Hub reference.
§Returns
  • u64 - Current revision number.
Source

pub fn publish( &self, kind: HmrEventKind, message: String, changed_files: Vec<String>, ) -> u64

Increments the revision counter and publishes a new HmrEvent to all SSE subscribers.

§Arguments
  • &Self - Hub reference.
  • HmrEventKind - Event variant (Reload, OtaUpdate, or BuildError).
  • String - Human-readable event description.
  • Vec<String> - List of changed source paths.
§Returns
  • u64 - Newly assigned revision number.
Source

pub fn set_ota_state(&self, next_state: OtaBundleState)

Replaces the active signed Dynamic WASM OTA bundle served over HTTP.

§Arguments
  • &Self - Hub reference.
  • OtaBundleState - Freshly compiled and signed OTA artifact.
Source

pub fn current_event(&self) -> Option<HmrEvent>

Returns a cloned copy of the latest published HmrEvent.

§Arguments
  • &Self - Hub reference.
§Returns
  • Option<HmrEvent> - Latest event snapshot.
Source

pub fn ota_snapshot(&self) -> Option<OtaBundleState>

Returns a cloned snapshot of the active OTA manifest and .wasm bytes.

§Arguments
  • &Self - Hub reference.
§Returns
  • Option<OtaBundleState> - Active OTA artifact if lock is unpoisoned.
Source

pub fn stop(&self)

Signals all background HTTP and watcher threads to exit cleanly.

§Arguments
  • &Self - Hub reference.
Source

pub fn is_running(&self) -> bool

Returns true while the dev server has not been shut down.

§Arguments
  • &Self - Hub reference.
§Returns
  • bool - Running state flag.

Trait Implementations§

Source§

impl Debug for HmrHub

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl !Freeze for HmrHub

§

impl Forget for HmrHub

§

impl Move for HmrHub

§

impl RefUnwindSafe for HmrHub

§

impl Send for HmrHub

§

impl Sync for HmrHub

§

impl Unpin for HmrHub

§

impl UnsafeUnpin for HmrHub

§

impl UnwindSafe for HmrHub

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> 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, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

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.