Struct simple_actor::Actor
source · [−]pub struct Actor<T: 'static + Send>(_);Expand description
Actor wrapping a state.
Implementations
sourceimpl<T: 'static + Send> Actor<T>
impl<T: 'static + Send> Actor<T>
sourcepub fn new(state: T) -> (Self, impl Future<Output = ()>)
pub fn new(state: T) -> (Self, impl Future<Output = ()>)
Creates a new Actor with default inbound channel capacity (1024).
Returned future must be spawned in an async executor.
sourcepub fn new_with_capacity(
state: T,
capacity: usize
) -> (Self, impl Future<Output = ()>)
pub fn new_with_capacity(
state: T,
capacity: usize
) -> (Self, impl Future<Output = ()>)
Creates a new Actor with given capacity for its inbound channel.
Returned future must be spawned in an async executor.
sourcepub fn invoke<F, R>(&self, invoke: F) -> impl Future<Output = Option<R>> where
F: FnOnce(&mut T) -> R + 'static + Send,
R: 'static + Send,
pub fn invoke<F, R>(&self, invoke: F) -> impl Future<Output = Option<R>> where
F: FnOnce(&mut T) -> R + 'static + Send,
R: 'static + Send,
Interact with the state.
Returns None if the actor is no longer running.
Trait Implementations
Auto Trait Implementations
impl<T> !RefUnwindSafe for Actor<T>
impl<T> Send for Actor<T>
impl<T> Sync for Actor<T>
impl<T> Unpin for Actor<T>
impl<T> !UnwindSafe for Actor<T>
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more