Skip to main content

ForeignContext

Struct ForeignContext 

Source
pub struct ForeignContext<'a>(/* private fields */);
Expand description

A handle to a context that may become invalid under specific conditions.

Can only be obtained through CurrentContext::foreign_context_from_object.

Assumes the context was NOT constructed by the current extension. Accessing its associated native data is therefore unsafe.

Invalidity only occurs after the associated ExtensionContext object has been disposed. Therefore, callers should be prepared for operations on the context to fail at appropriate points.

This crate leverages FREGetFREContextFromExtensionContext to enable more advanced use cases, but doing so also increases overall complexity.

Implementations§

Source§

impl<'a> ForeignContext<'a>

Source

pub fn get_native_data(self) -> Result<Option<NonNullFREData>, FfiError>

Returns a pointer to the native data. Callers must understand its memory layout and explicitly treat it as either a borrow or a move.

Only fails if the context is invalid.

Source

pub unsafe fn set_native_data( self, data: Option<NonNullFREData>, ) -> Result<(), FfiError>

Sets the native data pointer for the context.

Only fails if the context is invalid.

§Safety

Callers must ensure that no valid native data is currently set, or that any previously associated native data has become invalid and its memory has been properly released.

If data is a non-null pointer, it must have well-defined ownership: it must be treated explicitly as either a borrow or a move.

If treated as a move, callers must ensure that the memory is properly released before FREContextFinalizer completes.

Source

pub fn get_actionscript_data(self) -> Result<Object<'a>, FfiError>

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

ExtensionContext.actionScriptData

Only fails if the context is invalid.

Source

pub fn set_actionscript_data(self, object: Object<'_>) -> Result<(), FfiError>

Sets the ActionScript-side Context Data associated with the context.

ExtensionContext.actionScriptData

Only fails if the context is invalid.

Trait Implementations§

Source§

impl<'a> Clone for ForeignContext<'a>

Source§

fn clone(&self) -> ForeignContext<'a>

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Context for ForeignContext<'_>

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 event_dispatcher(&self) -> EventDispatcher

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

fn trace(&self, message: impl ToUcstrLossy)

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

fn get_render_mode( &self, stage: Option<Object<'_>>, ) -> Result<RenderMode, FfiError>

Return Err if stage is non-null but not a Stage object Read more
Source§

fn set_render_source( &self, media_buffer: Object<'_>, sprite: Object<'_>, ) -> Result<(), FfiError>

air.media.MediaBuffer (AIR SDK 51) Read more
Source§

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

This is a minimal safety wrapper around the underlying FFI. Its current placement, shape, and usage are not ideal, and it is expected to be refactored if the ANE C API allows more precise determination of an object’s concrete type.
Source§

impl<'a> Debug for ForeignContext<'a>

Source§

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

Formats the value using the given formatter. Read more
Source§

impl<'a> PartialEq for ForeignContext<'a>

Source§

fn eq(&self, other: &ForeignContext<'a>) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl<'a> Copy for ForeignContext<'a>

Source§

impl<'a> Eq for ForeignContext<'a>

Source§

impl<'a> StructuralPartialEq for ForeignContext<'a>

Auto Trait Implementations§

§

impl<'a> Freeze for ForeignContext<'a>

§

impl<'a> RefUnwindSafe for ForeignContext<'a>

§

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

§

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

§

impl<'a> Unpin for ForeignContext<'a>

§

impl<'a> UnsafeUnpin for ForeignContext<'a>

§

impl<'a> UnwindSafe for ForeignContext<'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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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.