fre-sys 0.1.1

Rust bindings for the Flash Runtime Extension (FRE) C API in AIR.
Documentation
  • Coverage
  • 60.83%
    73 out of 120 items documented1 out of 11 items with examples
  • Size
  • Source code size: 54.04 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 6.35 MB This is the summed size of all files generated by rustdoc for all configured targets
  • Ø build duration
  • this release: 42s Average build duration of successful builds.
  • all releases: 39s Average build duration of successful builds in releases after 2024-10-23.
  • Links
  • frashack/fre-sys
    0 0 0
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • frashack

fre-sys

Rust bindings for the AIR SDK C API (FlashRuntimeExtensions.h), used to build Flash Runtime Extensions (FRE).

This crate requires the AIR SDK.

The AIR SDK is currently maintained by Harman (Samsung), originally developed by Adobe.

You must obtain the AIR SDK from the official distributor (currently Harman) and set it up manually.

This project does not distribute any proprietary SDK files.

Most users should use fre-rs, which provides a safer and more ergonomic abstraction over this crate.

References

Safety

This crate provides low-level bindings over the AIR runtime:

  • Underlying objects may be modified externally by the runtime.
  • No guarantee of exclusive access.
  • Correct usage of the AIR C API is required.

Users must ensure correct lifetimes and ownership assumptions.

License

MIT OR Apache-2.0

Example

use fre_sys::prelude::*;
#[allow(unsafe_op_in_unsafe_fn, non_snake_case, unused_variables)]
#[unsafe(no_mangle)]
pub unsafe extern "C" fn Initializer (
    ext_data_to_set: *mut FREData,
    ctx_initializer_to_set: *mut FREContextInitializer,
    ctx_finalizer_to_set: *mut FREContextFinalizer,
) {
    *ctx_initializer_to_set = ctx_initializer;
}
#[allow(unsafe_op_in_unsafe_fn, unused_variables)]
unsafe extern "C" fn ctx_initializer (
    ext_data: FREData,
    ctx_type: FREStr,
    ctx: FREContext,
    num_funcs_to_set: *mut u32,
    funcs_to_set: *mut *const FRENamedFunction,
) {
    *num_funcs_to_set = 1;
    *funcs_to_set = std::mem::transmute(&FUNC);
}
#[repr(transparent)]
struct Function (FRENamedFunction);
unsafe impl Sync for Function {}
static FUNC: Function = Function(FRENamedFunction {
    name: c"hello_extension".as_ptr() as FREStr,
    functionData: std::ptr::null_mut(),
    function: hello,
});
unsafe extern "C" fn hello(_: FREContext, _: FREData, _: u32, _: *const FREObject) -> FREObject {
    let bytes = "Hello! Flash Runtime".as_bytes();
    let mut str_obj = std::ptr::null_mut();
    _ = unsafe {FRENewObjectFromUTF8(bytes.len() as u32, bytes.as_ptr(), &mut str_obj)};
    str_obj
}