pub struct ForeignContext<'a>(/* private fields */);Expand description
A handle to a context that may become invalid under specific conditions.
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>
impl<'a> ForeignContext<'a>
Sourcepub fn from_object(context: NonNullObject<'a>) -> Result<Self, ContextError>
pub fn from_object(context: NonNullObject<'a>) -> Result<Self, ContextError>
Returns the associated context from an AS3 ExtensionContext object.
§Errors
ContextError::FfiCallFailedIfcontextis not anExtensionContextobject.ContextError::ContextConflictIf it is associated with the current context.
Sourcepub fn get_native_data(self) -> Result<Option<NonNullFREData>, FfiError>
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.
Sourcepub unsafe fn set_native_data(
self,
data: Option<NonNullFREData>,
) -> Result<(), FfiError>
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.
Sourcepub fn get_actionscript_data(self) -> Result<Object<'a>, FfiError>
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.
Trait Implementations§
Source§impl<'a> Clone for ForeignContext<'a>
impl<'a> Clone for ForeignContext<'a>
Source§fn clone(&self) -> ForeignContext<'a>
fn clone(&self) -> ForeignContext<'a>
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl<'a> Context<'a> for ForeignContext<'a>
impl<'a> Context<'a> for ForeignContext<'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.