uniffi

Struct ForeignExecutor

Source
pub struct ForeignExecutor { /* private fields */ }
Expand description

Reexport items from other uniffi creates Schedule Rust calls using a foreign executor

Implementations§

Source§

impl ForeignExecutor

Source

pub fn new(executor: ForeignExecutorHandle) -> ForeignExecutor

Source

pub fn schedule<F>(&self, delay: u32, task: F)
where F: FnOnce() + Send + 'static + UnwindSafe,

Schedule a closure to be run.

This method can be used for “fire-and-forget” style calls, where the calling code doesn’t need to await the result.

Closure requirements:

  • Send: since the closure will likely run on a different thread
  • ’static: since it runs at an arbitrary time, so all references need to be ’static
  • panic::UnwindSafe: if the closure panics, it should not corrupt any data
Source

pub async fn run<F, T>(&self, delay: u32, closure: F) -> T
where F: FnOnce() -> T + Send + 'static + UnwindSafe, T: Send + 'static,

Schedule a closure to be run and get a Future for the result

Closure requirements:

  • Send: since the closure will likely run on a different thread
  • ’static: since it runs at an arbitrary time, so all references need to be ’static
  • panic::UnwindSafe: if the closure panics, it should not corrupt any data

Trait Implementations§

Source§

impl<UT> ConvertError<UT> for ForeignExecutor

Source§

impl Debug for ForeignExecutor

Source§

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

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

impl Drop for ForeignExecutor

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more
Source§

impl<UT> FfiConverter<UT> for ForeignExecutor

FFI support for ForeignExecutor

These are passed over the FFI as opaque pointer-sized types representing the foreign executor. The foreign bindings may use an actual pointer to the executor object, or a usized integer handle.

Source§

const TYPE_ID_META: MetadataBuffer

Type ID metadata, serialized into a MetadataBuffer. Read more
Source§

type FfiType = ForeignExecutorHandle

The low-level type used for passing values of this type over the FFI. Read more
Source§

fn lower( executor: ForeignExecutor, ) -> <ForeignExecutor as FfiConverter<UT>>::FfiType

Lower a rust value of the target type, into an FFI value of type Self::FfiType. Read more
Source§

fn write(executor: ForeignExecutor, buf: &mut Vec<u8>)

Write a rust value into a buffer, to send over the FFI in serialized form. Read more
Source§

fn try_lift( executor: <ForeignExecutor as FfiConverter<UT>>::FfiType, ) -> Result<ForeignExecutor, Error>

Lift a rust value of the target type, from an FFI value of type Self::FfiType. Read more
Source§

fn try_read(buf: &mut &[u8]) -> Result<ForeignExecutor, Error>

Read a rust value from a buffer, received over the FFI in serialized form. Read more
Source§

impl<UT> Lift<UT> for ForeignExecutor

Source§

impl<UT> LiftRef<UT> for ForeignExecutor

Source§

impl<UT> LiftReturn<UT> for ForeignExecutor

Source§

const TYPE_ID_META: MetadataBuffer

Source§

fn lift_callback_return(buf: RustBuffer) -> ForeignExecutor

Lift a Rust value for a callback interface method result
Source§

fn lift_callback_error(_buf: RustBuffer) -> Self

Lift a Rust value for a callback interface method error result Read more
Source§

fn handle_callback_unexpected_error(e: UnexpectedUniFFICallbackError) -> Self

Lift a Rust value for an unexpected callback interface error Read more
Source§

impl<UT> Lower<UT> for ForeignExecutor

Source§

impl<UT> LowerReturn<UT> for ForeignExecutor

Source§

const TYPE_ID_META: MetadataBuffer

Source§

type ReturnType = <ForeignExecutor as Lower<UT>>::FfiType

The type that should be returned by scaffolding functions for this type. Read more
Source§

fn lower_return( obj: ForeignExecutor, ) -> Result<<ForeignExecutor as LowerReturn<UT>>::ReturnType, RustBuffer>

Lower this value for scaffolding function return Read more
Source§

fn handle_failed_lift(arg_name: &str, e: Error) -> Self

If possible, get a serialized error for failed argument lifts Read more

Auto Trait Implementations§

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.