pub struct CurrentContext<'a>(/* private fields */);Expand description
The current ANE context, on which most APIs in this crate depend.
The lifetime is strictly tied to the function call stack.
§Invariants
During any context-related call, the current context is guaranteed to be
valid, and its associated AS3 ExtensionContext object must not call dispose.
Violating these invariants may cause subsequent API calls to fail and lead to rapidly increasing complexity in error handling. This crate treats such situations as invalid state and does not attempt to recover from them.
Implementations§
Source§impl<'a> CurrentContext<'a>
impl<'a> CurrentContext<'a>
Sourcepub fn ty(&self) -> Option<UCStr>
pub fn ty(&self) -> Option<UCStr>
Returns the context type associated with the current context.
This corresponds to the contextType argument passed to
ExtensionContext.createExtensionContext.
Returns None if that argument was null.
Sourcepub fn data(&self) -> Option<&dyn Any>
pub fn data(&self) -> Option<&dyn Any>
Returns an immutable reference to the Context Data associated with the current context.
Context Data is user-defined data bound to the context, sharing the same lifetime as the context itself.
It can only be set via the first return value of ContextInitializer.
Sourcepub fn data_mut(&mut self) -> Option<&mut dyn Any>
pub fn data_mut(&mut self) -> Option<&mut dyn Any>
Returns a mutable reference to the Context Data associated with the current context.
Context Data is user-defined data bound to the context, sharing the same lifetime as the context itself.
It can only be set via the first return value of ContextInitializer.
Sourcepub fn construct(
&self,
class: UCStr,
args: Option<&[Object<'_>]>,
) -> Result<NonNullObject<'a>, ExternalError<'a>>
pub fn construct( &self, class: UCStr, args: Option<&[Object<'_>]>, ) -> Result<NonNullObject<'a>, ExternalError<'a>>
Calls the constructor for the specified class.
Sourcepub fn call_method(
&mut self,
name: &str,
args: Option<&[Object<'_>]>,
) -> Result<Object<'a>, ContextError>
pub fn call_method( &mut self, name: &str, args: Option<&[Object<'_>]>, ) -> Result<Object<'a>, ContextError>
Calls a method associated with the current context.
Methods can only be set via the second return value of ContextInitializer.
Err=> ContextError::MethodsNotRegistered, ContextError::MethodNotFound;
Sourcepub fn get_actionscript_data(&self) -> Object<'a>
pub fn get_actionscript_data(&self) -> Object<'a>
Returns the ActionScript-side Context Data associated with the current context.
ExtensionContext.actionScriptData
Sourcepub fn set_actionscript_data(&self, object: Object<'_>)
pub fn set_actionscript_data(&self, object: Object<'_>)
Sets the ActionScript-side Context Data associated with the current context.
ExtensionContext.actionScriptData
Trait Implementations§
Source§impl<'a> Context<'a> for CurrentContext<'a>
impl<'a> Context<'a> for CurrentContext<'a>
fn as_handle(&self) -> NonNull<c_void>
fn as_ptr(&self) -> FREContext
Source§fn trace<T: ToUcstrLossy + Sized>(&self, message: T)
fn trace<T: ToUcstrLossy + Sized>(&self, message: T)
Source§fn event_dispatcher(&self) -> EventDispatcher
fn event_dispatcher(&self) -> EventDispatcher
EventDispatcher used to perform asynchronous callbacks
via the AS3 event system.