pub unsafe trait AsObject<'a>:
Sized
+ Copy
+ Eq
+ Display
+ Into<FREObject>
+ Into<Object<'a>> {
const TYPE: Type;
// Provided methods
fn as_object(self) -> Object<'a> { ... }
fn as_ptr(self) -> FREObject { ... }
fn is_null(self) -> bool { ... }
fn get_type(self) -> Type { ... }
fn get_property(self, name: UCStr) -> Result<Object<'a>, ExternalError<'a>> { ... }
fn set_property<O: AsObject<'a>>(
self,
name: UCStr,
value: O,
) -> Result<(), ExternalError<'a>> { ... }
fn call_method(
self,
name: UCStr,
args: Option<&[Object<'_>]>,
) -> Result<Object<'a>, ExternalError<'a>> { ... }
fn toString(self) -> Result<StringObject<'a>, ExternalError<'a>> { ... }
}Expand description
An abstraction over objects of all types.
In typical usage of this crate, this trait should not be implemented directly.
This trait represents a common interface for types that are backed by an FREObject.
It is only intended to be implemented when defining a new object type.
§Safety
Implementing this trait requires strict guarantees about memory layout.
The implementing type must be layout-compatible with FREObject.
In practice, this means it must be annotated with #[repr(transparent)]
and wrap the underlying FREObject without altering its representation.
This requirement exists because the methods provided by this trait may perform reinterpretation of the underlying memory. Failure to uphold these guarantees will result in undefined behavior.
Required Associated Constants§
Provided Methods§
fn as_object(self) -> Object<'a>
fn as_ptr(self) -> FREObject
fn is_null(self) -> bool
fn get_type(self) -> Type
fn get_property(self, name: UCStr) -> Result<Object<'a>, ExternalError<'a>>
fn set_property<O: AsObject<'a>>( self, name: UCStr, value: O, ) -> Result<(), ExternalError<'a>>
fn call_method( self, name: UCStr, args: Option<&[Object<'_>]>, ) -> Result<Object<'a>, ExternalError<'a>>
Sourcefn toString(self) -> Result<StringObject<'a>, ExternalError<'a>>
fn toString(self) -> Result<StringObject<'a>, ExternalError<'a>>
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.