FerroUI/ docs

Search guides, controls, Rust APIs, and XAML.

    GitHub ↗

    PatchSupervisor

    struct · ferroui-hot-patch · v0.5.0

    struct PatchSupervisor
    

    A snapshot includes every Rust source, manifest, lockfile, build script, and configuration input. Source bytes must come from the exact build that produced the running executable.

    View source

    Members

    new

    fn new(baseline: SourceSnapshot, registered: BTreeMap<String, BTreeSet<String>>) -> Self
    

    Source

    with_registrations

    fn with_registrations(baseline: SourceSnapshot, registrations: impl IntoIterator<Item = crate::FunctionRegistration>) -> Result<Self, String>
    

    Validate explicit callback and builder registrations against the running executable's source baseline. Registrations remain fixed for this process.

    Source

    revision

    fn revision(self: &Self) -> u64
    

    Source

    admit

    fn admit(self: &Self, sources: SourceSnapshot) -> Result<AdmittedPatch, String>
    

    Source

    apply

    unsafe fn apply(self: &mut Self, patch: AdmittedPatch, current: &SourceSnapshot, table: subsecond::JumpTable) -> Result<u64, String>
    

    Apply on the UI thread between callbacks, only after the patch build succeeded. current is reread after the build; superseded builds cannot load their code.

    Safety

    The table must be produced by the matching Subsecond toolchain against this running executable, exclusively from patch's admitted source snapshot. Every non-source build input and dependency must be unchanged. The caller must ensure no other thread is executing patchable code. Source admission cannot validate machine addresses or compiler ABI. This supervisor must be the exclusive dispatch-table owner; independent Subsecond owners and registered Subsecond reload handlers are unsupported.

    Source

    apply_with

    unsafe fn apply_with(self: &mut Self, patch: AdmittedPatch, current: &SourceSnapshot, table: subsecond::JumpTable, transaction: impl FnOnce() -> Result<(), String>) -> Result<u64, String>
    

    Install code provisionally and run a reversible view transaction with the new function bodies. Publish the code revision only if that transaction succeeds. On failure or panic, restore the previously accepted dispatch table; an initial failed patch restores dispatch to the original executable. The transaction must itself restore UI mutations before returning an error or unwinding. This method cannot undo arbitrary application side effects. It must reapply patch.views_to_reapply() through application adapters, or fail; callback-only changes do not request any view reapplication.

    Safety

    All of apply's guarantees apply. Retain every accepted patch artifact, unmodified, until this supervisor and its process retire. No independent Subsecond owner or registered Subsecond hot-reload handlers may mutate the dispatch table or UI. The transaction must not publish work that executes patchable code on another thread or after a rejected transaction.

    Source

    restart_required

    fn restart_required(self: &Self) -> Option<&str>
    

    A failed dispatch rollback makes further admission unsafe. The owning development process must build and start a replacement before continuing.

    Source

    Trait implementations

    • Send
    • Sync
    • Freeze
    • UnsafeUnpin
    • Unpin
    • UnwindSafe
    • RefUnwindSafe
    • Borrow<T>
    • BorrowMut<T>
    • Into<U>
    • From<T>
    • TryInto<U>
    • TryFrom<U>
    • Any

    Availability

    Extracted for aarch64-apple-darwin. Cargo features are listed in the crate index.