pub unsafe trait AsObject<'a>:
Sealed
+ Sized
+ Debug
+ Display
+ Copy
+ Into<Object<'a>>
+ Into<FREObject> {
const TYPE: Type;
// Provided methods
fn as_object(self) -> Object<'a> { ... }
unsafe fn as_unchecked<T: AsObject<'a>>(self) -> T { ... }
unsafe fn from_unchecked<O: AsObject<'a>>(object: O) -> Self { ... }
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<String<'a>, ExternalError<'a>> { ... }
}Expand description
An abstraction over all AS3 objects.
This trait is Sealed and should not be implemented manually.
To define a new AS3 class, use the class! macro.
§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>
Sourceunsafe fn as_unchecked<T: AsObject<'a>>(self) -> T
unsafe fn as_unchecked<T: AsObject<'a>>(self) -> T
Casts this object to T without checks.
Prefer to use TryAs::try_as instead whenever possible.
§Safety
The concrete object type must be fully determined, must be type-checked
and validated in AS3, and the conversion must strictly follow the
semantics of the AS3 as operator.
Violating these requirements may cause related APIs to perform illegal FFI calls, which may panic even if those APIs do not explicitly document panics. Violations may also result in undefined behavior.
Sourceunsafe fn from_unchecked<O: AsObject<'a>>(object: O) -> Self
unsafe fn from_unchecked<O: AsObject<'a>>(object: O) -> Self
Casts an object to Self without checks.
Prefer to use TryAs::try_as instead whenever possible.
§Safety
The concrete object type must be fully determined, must be type-checked
and validated in AS3, and the conversion must strictly follow the
semantics of the AS3 as operator.
Violating these requirements may cause related APIs to perform illegal FFI calls, which may panic even if those APIs do not explicitly document panics. Violations may also result in undefined behavior.
fn as_ptr(self) -> FREObject
fn is_null(self) -> bool
Sourcefn get_type(self) -> Type
fn get_type(self) -> Type
Returns the runtime type of the object.
The result depends on the underlying FREGetObjectType implementation.
Most unsupported types return Type::NonNullObject.
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>>
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.