Skip to main content

CurrentContext

Struct CurrentContext 

Source
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>

Source

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.

Source

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.

Source

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.

Source

pub fn construct( &self, class: UCStr, args: Option<&[Object<'_>]>, ) -> Result<NonNullObject<'a>, ExternalError<'a>>

Calls the constructor for the specified class.

Source

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;

Source

pub fn get_actionscript_data(&self) -> Object<'a>

Returns the ActionScript-side Context Data associated with the current context.

ExtensionContext.actionScriptData

Source

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>

Source§

fn as_handle(&self) -> NonNull<c_void>

Source§

fn is_valid(&self) -> bool

Returns whether the context is valid. Read more
Source§

fn as_ptr(&self) -> FREContext

Source§

fn trace<T: ToUcstrLossy + Sized>(&self, message: T)

Sends a message to the debugger output. Read more
Source§

fn event_dispatcher(&self) -> EventDispatcher

Returns an EventDispatcher used to perform asynchronous callbacks via the AS3 event system.
Source§

fn get_render_mode(&self, stage: Option<Stage<'a>>) -> RenderMode

Returns the render mode of the stage. Read more
Source§

fn set_render_source( &self, source: MediaBuffer<'a>, display_object: NonNullObject<'a>, ) -> Result<(), FfiError>

Source§

fn with_media_buffer<F, R>(&self, media_buffer: MediaBuffer<'a>, f: F) -> R
where F: FnOnce(MediaBufferDataAdapter<'_>) -> R,

Source§

impl<'a> Debug for CurrentContext<'a>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<'a> Freeze for CurrentContext<'a>

§

impl<'a> RefUnwindSafe for CurrentContext<'a>

§

impl<'a> !Send for CurrentContext<'a>

§

impl<'a> !Sync for CurrentContext<'a>

§

impl<'a> Unpin for CurrentContext<'a>

§

impl<'a> UnsafeUnpin for CurrentContext<'a>

§

impl<'a> UnwindSafe for CurrentContext<'a>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.