Struct soroban_env_guest::Object
source · pub struct Object(_);
Expand description
Wrapper for a RawVal that is tagged with Tag::Object, interpreting the RawVal’s body as a pair of a 28-bit object-type code and a 32-bit handle to a host object of the object-type. The object-type codes correspond to the enumerated cases of ScObject, and the handle values are dynamically assigned by the host as new objects are allocated during execution.
Implementations§
source§impl Object
impl Object
pub const fn is_obj_type(&self, ty: ScObjectType) -> bool
pub const fn get_handle(&self) -> u32
pub fn val_is_obj_type(v: RawVal, ty: ScObjectType) -> bool
pub fn from_type_and_handle(ty: ScObjectType, handle: u32) -> Object
Trait Implementations§
source§impl RawValConvertible for Object
impl RawValConvertible for Object
source§fn is_val_type(v: RawVal) -> bool
fn is_val_type(v: RawVal) -> bool
Returns
true
if v
is in a union state compatible with Self
.source§unsafe fn unchecked_from_val(v: RawVal) -> Object
unsafe fn unchecked_from_val(v: RawVal) -> Object
Converts the bits making up a
RawVal
into Self
without checking
that the RawVal
is tagged correctly, assuming that such a check has
been performed elsewhere. It is the caller’s responsibility to arrange
that such checks have occurred before calling unchecked_from_val
,
which is why it is marked as unsafe
(it does not represent a risk of
memory-unsafety, merely “serious logic errors”). Read moresource§fn try_convert(v: RawVal) -> Option<Self>
fn try_convert(v: RawVal) -> Option<Self>
Attempt a conversion from
RawVal
to Self
, returning None
if the
provided RawVal
is not tagged correctly. By default this calls
Self::is_val_type
and Self::unchecked_from_val
, but it can be
customized on a type-by-type basis to avoid redundant tag tests and
produce more efficient code, as it is done for Static
values like
bool
. Read more