HotReloadSession
struct · ferroui-hot-reload · v0.5.0
struct HotReloadSession
Sources become authoritative only after every affected live target commits successfully.
Session ownership is intentionally !Send: callers must pump it on the UI thread.
Members
newfor_runtime_documentsregister_documentbind_classregister_targettrack_resource_includestrack_style_includessubmitreapply_documentsubmit_textssubmit_filessourcesapplied_revisionhas_pending_changesapply_pendingapply_pending_with
new
fn new() -> Self
for_runtime_documents
fn for_runtime_documents() -> Self
Creates a session for runtime-instantiated documents whose target adapters replace the entire affected object graph, including namescopes and event subscriptions. Structural contracts are accepted only after every target commits successfully. Compiled class population overrides are prohibited in this mode; application and manifest sessions retain the default restart protection for contract changes.
register_document
fn register_document(self: &mut Self, uri: String, source: String) -> Result<(), ReloadError>
bind_class
fn bind_class(self: &mut Self, class: &'static ferroui_base::TypeInfo, uri: String, configuration: ferroui_markup_xaml::RuntimeXamlLoaderConfiguration) -> Result<(), ReloadError>
New instances populate from the last accepted snapshot. Existing instances need a ReloadTarget adapter; this hook never clears a live root.
register_target
fn register_target(self: &mut Self, target: &Rc<dyn ReloadTarget>)
The application owns its adapters. Closed components disappear when their adapters are dropped.
track_resource_includes
fn track_resource_includes(self: &mut Self, owner: &ferroui_base::Ref<ferroui_base::controls::ResourceDictionary>, configuration: ferroui_markup_xaml::RuntimeXamlLoaderConfiguration)
Track direct resource includes in this container, including later additions and removals. Only includes whose documents belong to this session are adopted. Owners are weakly held. Repeated registration keeps the first configuration. All registered targets conservatively depend on these includes, so static consumers prepare with the same resource revision. Do not also manually register adapters for the same contributions.
track_style_includes
fn track_style_includes(self: &mut Self, owner: &ferroui_base::Ref<ferroui_base::styling::Styles>, configuration: ferroui_markup_xaml::RuntimeXamlLoaderConfiguration)
Track direct style includes with the same ownership and dependency rules as
track_resource_includes. Arbitrary inline styles need explicit adapters.
submit
fn submit(self: &mut Self, uri: String, text: String) -> u64
reapply_document
fn reapply_document(self: &mut Self, uri: &str) -> Result<u64, ReloadError>
Reapply an explicitly registered view after its Rust builder changes. Keep a pending editor draft and any read errors: a builder request must not silently replace newer text with the accepted source or hide a failure.
submit_texts
fn submit_texts(self: &mut Self, documents: impl IntoIterator<Item = (String, String)>) -> u64
Submit editor/supervisor text as one revision, without rebuilding targets
for unchanged accepted documents. Returning to accepted text discards that
document's failed draft; drafts and read errors for other documents remain.
Resubmitting a pending draft explicitly retries its failed transaction.
Use submit when a view must be reapplied even with identical markup.
submit_files
fn submit_files(self: &mut Self, batch: FileBatch) -> u64
Submit a complete watcher snapshot as one revision. Read errors block the transaction, including older pending edits, until that document recovers. Editors can recover an unreadable file by submitting its unsaved text.
sources
fn sources(self: &Self) -> Rc<Sources>
applied_revision
fn applied_revision(self: &Self) -> u64
has_pending_changes
fn has_pending_changes(self: &Self) -> bool
apply_pending
fn apply_pending(self: &mut Self) -> Option<ReloadOutcome>
apply_pending_with
fn apply_pending_with(self: &mut Self, finalize: impl FnOnce() -> Result<(), ReloadError>) -> Option<ReloadOutcome>
Coordinate an external update with the markup transaction. The callback runs once, after every target commits but before accepted sources publish and old graphs/subscriptions are released. A callback error rolls back all target commits. Preparation/commit failure never invokes the callback.
The callback must leave its own state unchanged on error or panic. After
success, adapter finish is infallible cleanup: it must not panic. This
cannot roll back arbitrary external effects or an already installed patch.
A supervisor can install a validated synchronous function patch here and
publish both revisions only after installation succeeds. Observers invoked
synchronously by adapter commit still see the provisional graph; adapters
must honor their existing reversible-side-effect contract.
Trait implementations
SendSyncFreezeUnsafeUnpinUnpinUnwindSafeRefUnwindSafeBorrow<T>BorrowMut<T>Into<U>From<T>TryInto<U>TryFrom<U>AnyClassDefaultsErasedDestructorIntoEitherDefaultDrop
Availability
Extracted for aarch64-apple-darwin. Cargo features are listed in the crate index.