[][src]Struct ghost_actor::GhostActor

pub struct GhostActor<T: 'static + Send>(_);

GhostActor manages task efficient sequential mutable access to internal state data (type T). GhostActors are 'static and cheaply clone-able. A clone retains a channel to the same internal state data.

Implementations

impl<T: 'static + Send> GhostActor<T>[src]

pub fn new(t: T) -> (Self, GhostDriver)[src]

Create a new GhostActor with default config and initial state.

pub fn new_config(config: GhostConfig, t: T) -> (Self, GhostDriver)[src]

Create a new GhostActor with config and initial state.

pub fn to_boxed(&self) -> BoxGhostActor[src]

Get a type-erased BoxGhostActor version of this handle.

pub fn invoke_async<R, E, F>(&self, invoke: F) -> GhostFuture<R, E>

Notable traits for GhostFuture<R, E>

impl<R, E> Future for GhostFuture<R, E> where
    E: 'static + From<GhostError> + Send
type Output = Result<R, E>;
where
    R: 'static + Send,
    E: 'static + From<GhostError> + Send,
    F: FnOnce(&mut T) -> Result<GhostFuture<R, E>, E> + 'static + Send
[src]

Push state read/mutation logic onto actor queue for processing, uses invoke() internally - but expects a future to be returned which is awaited internally to be more ergonomic.

pub fn invoke<R, E, F>(&self, invoke: F) -> GhostFuture<R, E>

Notable traits for GhostFuture<R, E>

impl<R, E> Future for GhostFuture<R, E> where
    E: 'static + From<GhostError> + Send
type Output = Result<R, E>;
where
    R: 'static + Send,
    E: 'static + From<GhostError> + Send,
    F: FnOnce(&mut T) -> Result<R, E> + 'static + Send
[src]

Push state read/mutation logic onto actor queue for processing.

pub fn is_active(&self) -> bool[src]

Returns true if the channel is still connected to the actor task.

pub fn shutdown(&self)[src]

Close the channel to the actor task. This will result in the task being dropped once all pending invocations have been processed.

Trait Implementations

impl<T: 'static + Send> AsGhostActor for GhostActor<T>[src]

impl<T: 'static + Send> Clone for GhostActor<T>[src]

impl<T: 'static + Send> Debug for GhostActor<T>[src]

impl<T: 'static + Send> Eq for GhostActor<T>[src]

impl<T: 'static + Send> Hash for GhostActor<T>[src]

impl<T: 'static + Send> PartialEq<GhostActor<T>> for GhostActor<T>[src]

Auto Trait Implementations

impl<T> !RefUnwindSafe for GhostActor<T>[src]

impl<T> Send for GhostActor<T>[src]

impl<T> Sync for GhostActor<T>[src]

impl<T> Unpin for GhostActor<T>[src]

impl<T> !UnwindSafe for GhostActor<T>[src]

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> Instrument 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.