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 current context method 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 call_method(
&mut self,
name: &str,
args: Option<&[Object<'a>]>,
) -> Result<Object<'a>, ContextError>
pub fn call_method( &mut self, name: &str, args: Option<&[Object<'a>]>, ) -> 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.
§Panic
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.
§Panic
Panics if context is not an ExtensionContext object,
or if it is associated with the current context.
Source§impl<'a> CurrentContext<'a>
impl<'a> CurrentContext<'a>
Sourcepub unsafe fn with<F, R>(ctx: &'a FREContext, f: F) -> Rwhere
F: FnOnce(&CurrentContext<'a>) -> R,
R: 'a,
pub unsafe fn with<F, R>(ctx: &'a FREContext, f: F) -> Rwhere
F: FnOnce(&CurrentContext<'a>) -> R,
R: 'a,
A wrapper used by FREContextInitializer, FREContextFinalizer, and
FREFunction that provides a safe stack-level execution environment.
In typical usage of this crate, this function should not be called directly.
§Safety
While all operations performed within this function are safe at the stack level, calling this function itself is unsafe and requires that all input arguments are valid. In particular, this function assumes it is invoked directly with arguments provided by the Flash runtime.
Violating these assumptions may lead to undefined behavior.
Sourcepub unsafe fn with_context_initializer<F>(
ext_data: FREData,
ctx_type: FREStr,
ctx: &'a FREContext,
num_funcs_to_set: *mut u32,
funcs_to_set: *mut *const FRENamedFunction,
f: F,
)
pub unsafe fn with_context_initializer<F>( ext_data: FREData, ctx_type: FREStr, ctx: &'a FREContext, num_funcs_to_set: *mut u32, funcs_to_set: *mut *const FRENamedFunction, f: F, )
A wrapper around FREContextInitializer that provides a safe stack-level
execution environment for context initialization.
In typical usage of this crate, this function should not be called directly.
§Safety
While all operations performed within this function are safe at the stack level, calling this function itself is unsafe and requires the following conditions:
- The native data associated with
Contextmust not be accessed or managed by external code. - This function will construct a
ContextRegistryand assign it as the native data. The constructedContextRegistrymust be properly disposed inFREContextFinalizerto ensure its lifecycle is correctly terminated. - This function assumes it is invoked directly with arguments provided by the Flash runtime, meaning all arguments must be valid and consistent.
Violating these assumptions may lead to undefined behavior.
Sourcepub unsafe fn with_method<F, R>(
ctx: &'a FREContext,
func_data: FREData,
argc: u32,
argv: *const FREObject,
f: F,
) -> FREObject
pub unsafe fn with_method<F, R>( ctx: &'a FREContext, func_data: FREData, argc: u32, argv: *const FREObject, f: F, ) -> FREObject
A wrapper around FREFunction that provides a safe stack-level execution
environment for the given closure.
In typical usage of this crate, this function should not be called directly.
§Safety
While all operations performed within this function are safe at the stack level, calling this function itself is unsafe and requires the following conditions:
func_datamust either be constructed viaData::into_rawbeforeContextInitializerreturns, or be a null pointer.- This function assumes it is invoked directly with arguments provided by the Flash runtime, meaning all arguments must be valid and consistent.
Violating these assumptions may lead to undefined behavior.
Trait Implementations§
Source§impl Context for CurrentContext<'_>
impl Context for CurrentContext<'_>
fn as_handle(&self) -> NonNull<c_void>
fn as_ptr(&self) -> FREContext
Source§fn event_dispatcher(&self) -> EventDispatcher
fn event_dispatcher(&self) -> EventDispatcher
EventDispatcher used to perform asynchronous callbacks
via the ActionScript event system.Source§fn trace(&self, message: impl ToUcstrLossy)
fn trace(&self, message: impl ToUcstrLossy)
Source§fn get_render_mode(
&self,
stage: Option<Object<'_>>,
) -> Result<RenderMode, FfiError>
fn get_render_mode( &self, stage: Option<Object<'_>>, ) -> Result<RenderMode, FfiError>
Source§fn set_render_source(
&self,
media_buffer: Object<'_>,
sprite: Object<'_>,
) -> Result<(), FfiError>
fn set_render_source( &self, media_buffer: Object<'_>, sprite: Object<'_>, ) -> Result<(), FfiError>
air.media.MediaBuffer (AIR SDK 51) Read more