Skip to main content

Patcher

Struct Patcher 

Source
pub struct Patcher { /* private fields */ }

Implementations§

Source§

impl Patcher

Source

pub fn new( package: String, rustc_path: PathBuf, linker_path: PathBuf, cwd: PathBuf, patch_out_dir: PathBuf, target_os: LinkerOs, original_cache: HotpatchModuleCache, captured_rustc_args: HashMap<String, CapturedRustcInvocation>, captured_linker_args: HashMap<String, CapturedLinkerInvocation>, ) -> Self

Direct constructor. Tests use this to inject hand-built state (so they don’t have to run a real cargo build or touch the workspace).

Source

pub fn initialize( workspace_root: &Path, package: String, rustc_cache_dir: &Path, linker_cache_dir: &Path, real_linker: &Path, original_binary: &Path, target_os: LinkerOs, target_triple: Option<&str>, ) -> Result<Self>

Production setup. Fat build already done — the dev loop runs it through Builder::with_capture, so this constructor only needs to read the resulting caches and parse the original binary. Splitting the build out lets the dev loop reuse its existing initial-build phase rather than spawning cargo a second time.

original_binary is the file the device actually loaded — for Android that’s lib<crate>.so extracted from the APK or found under the Gradle-built jniLibs tree.

Source

pub async fn build_patch( &self, aslr_reference: u64, crate_key: Option<&str>, ) -> Result<PatchPlan>

Build a single hot-patch from a change. Returns the diff alongside the JumpTable so the dev loop can log warnings (added / removed / weak symbols).

aslr_reference is the runtime address of main reported by the connected device through the hello WebSocket handshake. We compute the ASLR slide as aslr_reference - cache.aslr_reference and bake the result into a small stub object that resolves every host symbol the patch references — see stub_object for the rationale. Pass 0 for cases where no device has connected yet (the patch will still build but won’t dispatch correctly at runtime; the caller should refrain from sending it in that state).

crate_key is the rustc-form name of the crate that owns the change. None defaults to the user crate. Sub-crate patches (#103) pass the changed crate’s name so the thin build picks up that crate’s captured rustc args (a fresh .o of the changed sub-crate), then links it into a patch dylib using the user crate’s linker invocation as template. The original user dylib already exports the sub-crate’s symbols (rustc linked its rlib in fat-build time); subsecond’s JumpTable redirects them onto the patch dylib’s new bodies.

Source

pub fn expected_patch_path(&self) -> PathBuf

Where this Patcher would put the next patch dylib — <patch_out_dir>/lib<crate>.{so,dylib,dll}. The filename is chosen for the target OS (e.g. Android’s .so even when the dev session runs on macOS) so the on-device runtime can recognise it.

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<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<A, B, T> HttpServerConnExec<A, B> for T
where B: Body,

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> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V