Skip to main content

PatchSupervisor

Struct PatchSupervisor 

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

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.

Implementations§

Source§

impl PatchSupervisor

Source

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

Source

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

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

Source

pub fn revision(&self) -> u64

Source

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

Source

pub unsafe fn apply( &mut self, patch: AdmittedPatch, current: &SourceSnapshot, table: 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

pub unsafe fn apply_with( &mut self, patch: AdmittedPatch, current: &SourceSnapshot, table: 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

pub fn restart_required(&self) -> Option<&str>

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

Auto Trait Implementations§

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.