Skip to content

bloqade.lanes.arch.spec.RustWrapper

← Module overview

classRustWrappersource

bloqade.lanes.arch.spec.RustWrapper

Bases: Generic[R]

Thin Python adapter over a PyO3 Rust object.

class RustWrapper

Subclasses set self._inner in __init__ (typically by constructing the underlying Rust type) and may add Python-specific properties or methods. Hash and equality delegate to the Rust object so wrappers behave consistently with Rust semantics — provided the Rust type implements __eq__ / __hash__. If it does not, the subclass should override these dunders explicitly (and ideally have the missing dunders pushed into the Rust core as a follow-up).

The from_inner classmethod wraps an existing Rust object without re-allocating. Use it whenever the Rust object already exists — for example, when wrapping the result of another Rust call:

.. code-block:: python

rust_src, rust_dst = arch._inner.lane_endpoints(lane._inner) return LocationAddress.from_inner(rust_src), LocationAddress.from_inner(rust_dst)