Skip to content

bloqade.lanes.bytecode.encoding.KirinRustWrapper

← Module overview

classKirinRustWrappersource

bloqade.lanes.bytecode.encoding.KirinRustWrapper

Bases: RustWrapper[R], ir.Data

:class:`RustWrapper` that also satisfies Kirin's ``ir.Data`` contract.

class KirinRustWrapper

Use this base for Rust types that appear as IR attributes (for example address types). Subclasses inherit:

  • from_inner — runs __post_init__ so the Kirin type attribute is initialised on wrappers built from existing Rust objects.
  • unwrap — returns self (the Python wrapper), preserving the wrapper identity through Kirin’s constprop pipeline. Kirin’s py.Constant interpreter calls unwrap() to obtain the value to store in const.Value; returning self._inner here would cause the raw Rust object (without ._inner) to be stored instead of the Python wrapper, breaking any downstream code that calls loc._inner.
  • encode — delegates to the Rust object’s encode method (most address types implement it). Override if the Rust type does not.
  • print_impl — prints the encoded address as a hex literal, matching the legacy Encoder formatting.

Subclasses must still define __init__ to construct self._inner and call self.__post_init__().