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.
§Invariant
During any context-related call, the current context is guaranteed to be
valid, and its associated ExtensionContext object must not call dispose.
Violating this invariant 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
Sourcepub unsafe fn cooperative_context_from_object(
&self,
context: Object<'a>,
) -> CooperativeContext<'a>
pub unsafe fn cooperative_context_from_object( &self, context: Object<'a>, ) -> CooperativeContext<'a>
Returns the associated context from an ExtensionContext object.
§Safety
context must be another context constructed by the current
extension via ContextInitializer. Otherwise, the invariants
of CooperativeContext are violated, and its internal APIs
for accessing native data will result in undefined behavior.
§Panics
Panics if context is not an ExtensionContext object,
or if it is associated with the current context.
Sourcepub fn foreign_context_from_object(
&self,
context: Object<'a>,
) -> ForeignContext<'a>
pub fn foreign_context_from_object( &self, context: Object<'a>, ) -> ForeignContext<'a>
Returns the associated context from an ExtensionContext object.
§Panics
Panics if context is not an ExtensionContext object,
or if it is associated with the current context.
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(&self, message: impl ToUcstrLossy)
fn trace(&self, message: impl ToUcstrLossy)
Source§fn event_dispatcher(&self) -> EventDispatcher
fn event_dispatcher(&self) -> EventDispatcher
EventDispatcher used to perform asynchronous callbacks
via the AS3 event system.