Skip to main content

Context

Trait Context 

Source
pub trait Context<'a>: Sealed {
    // Required methods
    fn as_handle(&self) -> NonNull<c_void>;
    fn is_valid(&self) -> bool;

    // Provided methods
    fn as_ptr(&self) -> FREContext { ... }
    fn trace<T: ToUcstrLossy + Sized>(&self, message: T) { ... }
    fn event_dispatcher(&self) -> EventDispatcher { ... }
    fn get_render_mode(&self, stage: Option<Stage<'a>>) -> RenderMode { ... }
    fn set_render_source(
        &self,
        source: MediaBuffer<'a>,
        display_object: NonNullObject<'a>,
    ) -> Result<(), FfiError> { ... }
    fn with_media_buffer<F, R>(&self, media_buffer: MediaBuffer<'a>, f: F) -> R
       where F: FnOnce(MediaBufferDataAdapter<'_>) -> R { ... }
}

Required Methods§

Source

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

Source

fn is_valid(&self) -> bool

Returns whether the context is valid.

The context remains valid until FREContextFinalizer has completed. Invalidity only occurs when the associated ExtensionContext object is destructed or its dispose method is explicitly called.

Provided Methods§

Source

fn as_ptr(&self) -> FREContext

Source

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

Sends a message to the debugger output.

Delivery is not guaranteed; the message may not be presented.

§Examples
use fre_rs::prelude::*;
fn func <'a> (ctx: &mut CurrentContext<'a>, args: &[Object<'a>]) {
    ctx.trace("Hello, Flash runtime!");
    ctx.trace(args);
    ctx.trace(args[0]);
}
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.

If stage is None, the main/initial stage is used.

Source

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

FRESetRenderSource

Returns Err if display_object has an incorrect type.

Source

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

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§

Source§

impl<'a> Context<'a> for CooperativeContext<'a>

Source§

impl<'a> Context<'a> for CurrentContext<'a>

Source§

impl<'a> Context<'a> for ForeignContext<'a>