[][src]Struct allo_isolate::Isolate

pub struct Isolate { /* fields omitted */ }

Simple wrapper around the Dart Isolate Port, nothing else.

Implementations

impl Isolate[src]

pub const fn new(port: i64) -> Self[src]

Create a new Isolate with a port obtained from Dart VM side.

Example

this a non realistic example lol :D

let isolate = Isolate::new(42);

pub fn post(&self, msg: impl IntoDart) -> bool[src]

Post an object to the Isolate over the port Object must implement IntoDart.

returns true if the message posted successfully, otherwise false

Safety

This assumes that you called store_dart_post_cobject and we have access to the Dart_PostCObject function pointer also, we do check if it is not null.

Example

let isolate = Isolate::new(42);
isolate.post("Hello Dart !");

pub async fn task<T, R>(self, t: T) -> bool where
    T: Future<Output = R> + Send + 'static,
    R: Send + IntoDart + 'static, 
[src]

Consumes Self, Runs the task, await for the result and then post it to the Isolate over the port Result must implement IntoDart.

returns true if the message posted successfully, otherwise false

Safety

This assumes that you called store_dart_post_cobject and we have access to the Dart_PostCObject function pointer also, we do check if it is not null.

Example

This example is not tested
use async_std::task;
let isolate = Isolate::new(42);
task::spawn(isolate.task(async { 1 + 2 }));

pub async fn catch_unwind<T, R>(self, t: T) -> Result<bool, Box<dyn Any + Send>> where
    T: Future<Output = R> + Send + 'static,
    R: Send + IntoDart + 'static, 
[src]

Similar to Isolate::task but with more logic to catch any panic and report it back

Trait Implementations

impl Clone for Isolate[src]

impl Copy for Isolate[src]

impl Debug for Isolate[src]

Auto Trait Implementations

impl RefUnwindSafe for Isolate

impl Send for Isolate

impl Sync for Isolate

impl Unpin for Isolate

impl UnwindSafe for Isolate

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.