Struct soroban_env_host::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”).source§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
.source§impl<E> TryFromVal<E, Object> for i128where
E: Env,
impl<E> TryFromVal<E, Object> for i128where
E: Env,
type Error = ConversionError
fn try_from_val(
env: &E,
val: Object
) -> Result<i128, <i128 as TryFromVal<E, Object>>::Error>
source§impl<E> TryFromVal<E, Object> for u128where
E: Env,
impl<E> TryFromVal<E, Object> for u128where
E: Env,
type Error = ConversionError
fn try_from_val(
env: &E,
val: Object
) -> Result<u128, <u128 as TryFromVal<E, Object>>::Error>
source§impl<E> TryFromVal<E, RawVal> for Objectwhere
E: Env,
impl<E> TryFromVal<E, RawVal> for Objectwhere
E: Env,
type Error = ConversionError
fn try_from_val(
_env: &E,
val: RawVal
) -> Result<Object, <Object as TryFromVal<E, RawVal>>::Error>
source§impl<'a, E> TryIntoVal<E, Object> for &'a ScObjectwhere
E: Env + Convert<&'a ScObject, Object>,
impl<'a, E> TryIntoVal<E, Object> for &'a ScObjectwhere
E: Env + Convert<&'a ScObject, Object>,
source§impl<E> TryIntoVal<E, Object> for &i128where
E: Env,
impl<E> TryIntoVal<E, Object> for &i128where
E: Env,
type Error = ConversionError
fn try_into_val(
self,
env: &E
) -> Result<Object, <&i128 as TryIntoVal<E, Object>>::Error>
source§impl<E> TryIntoVal<E, Object> for &u128where
E: Env,
impl<E> TryIntoVal<E, Object> for &u128where
E: Env,
type Error = ConversionError
fn try_into_val(
self,
env: &E
) -> Result<Object, <&u128 as TryIntoVal<E, Object>>::Error>
source§impl<E> TryIntoVal<E, Object> for RawValwhere
E: Env,
impl<E> TryIntoVal<E, Object> for RawValwhere
E: Env,
type Error = ConversionError
fn try_into_val(
self,
env: &E
) -> Result<Object, <RawVal as TryIntoVal<E, Object>>::Error>
source§impl<E> TryIntoVal<E, Object> for i128where
E: Env,
impl<E> TryIntoVal<E, Object> for i128where
E: Env,
type Error = ConversionError
fn try_into_val(
self,
env: &E
) -> Result<Object, <i128 as TryIntoVal<E, Object>>::Error>
source§impl<E> TryIntoVal<E, Object> for u128where
E: Env,
impl<E> TryIntoVal<E, Object> for u128where
E: Env,
type Error = ConversionError
fn try_into_val(
self,
env: &E
) -> Result<Object, <u128 as TryIntoVal<E, Object>>::Error>
source§impl<E> TryIntoVal<E, RawVal> for Objectwhere
E: Env,
impl<E> TryIntoVal<E, RawVal> for Objectwhere
E: Env,
type Error = ConversionError
fn try_into_val(
self,
_env: &E
) -> Result<RawVal, <Object as TryIntoVal<E, RawVal>>::Error>
source§impl<E> TryIntoVal<E, i128> for Objectwhere
E: Env,
impl<E> TryIntoVal<E, i128> for Objectwhere
E: Env,
type Error = ConversionError
fn try_into_val(
self,
env: &E
) -> Result<i128, <Object as TryIntoVal<E, i128>>::Error>
source§impl<E> TryIntoVal<E, u128> for Objectwhere
E: Env,
impl<E> TryIntoVal<E, u128> for Objectwhere
E: Env,
type Error = ConversionError
fn try_into_val(
self,
env: &E
) -> Result<u128, <Object as TryIntoVal<E, u128>>::Error>
impl Copy for Object
impl Val for Object
Auto Trait Implementations§
impl RefUnwindSafe for Object
impl Send for Object
impl Sync for Object
impl Unpin for Object
impl UnwindSafe for Object
Blanket Implementations§
source§impl<T, U, V, E, C> Compare<(T, U, V)> for Cwhere
C: Compare<T, Error = E, Error = E, Error = E> + Compare<U> + Compare<V>,
impl<T, U, V, E, C> Compare<(T, U, V)> for Cwhere
C: Compare<T, Error = E, Error = E, Error = E> + Compare<U> + Compare<V>,
source§impl<T, U, E, C> Compare<(T, U)> for Cwhere
C: Compare<T, Error = E, Error = E> + Compare<U>,
impl<T, U, E, C> Compare<(T, U)> for Cwhere
C: Compare<T, Error = E, Error = E> + Compare<U>,
source§impl<E> Compare<Object> for Ewhere
E: CheckedEnv,
impl<E> Compare<Object> for Ewhere
E: CheckedEnv,
§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
§fn into_any(self: Box<T, Global>) -> Box<dyn Any + 'static, Global>
fn into_any(self: Box<T, Global>) -> Box<dyn Any + 'static, Global>
Convert
Box<dyn Trait>
(where Trait: Downcast
) to Box<dyn Any>
. Box<dyn Any>
can
then be further downcast
into Box<ConcreteType>
where ConcreteType
implements Trait
.§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any + 'static>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any + 'static>
Convert
Rc<Trait>
(where Trait: Downcast
) to Rc<Any>
. Rc<Any>
can then be
further downcast
into Rc<ConcreteType>
where ConcreteType
implements Trait
.§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
Convert
&Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &Any
’s vtable from &Trait
’s.§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
Convert
&mut Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &mut Any
’s vtable from &mut Trait
’s.