pub struct ProcessRef<T>
where T: AbstractProcess,
{ /* private fields */ }
Expand description

A reference to a running AbstractProcess.

ProcessRef<T> is different from a Process in the ability to handle messages of different types, as long as the traits MessageHandler<Message>, RequestHandler<Request> or DeferredRequestHandler<Request> are implemented for T.

Implementations§

source§

impl<T> ProcessRef<T>
where T: AbstractProcess,

source

pub unsafe fn new(node_id: u64, process_id: u64) -> Self

Construct a process from a raw ID.

source

pub fn id(&self) -> u64

Returns the process ID.

source

pub fn node_id(&self) -> u64

Returns the node ID.

source

pub fn lookup<N: ProcessName + ?Sized>(name: &N) -> Option<Self>

Returns a process registered under name if it exists and the signature matches.

source

pub fn register<N: ProcessName>(&self, name: &N)

Registers process under name.

source

pub fn is_alive(&self) -> bool

Returns true for processes on the local node that are running.

Panics if called on a remote process.

Link process to the one currently running.

Link process to the one currently running with tag.

Unlink processes from the caller.

source

pub fn kill(&self)

Kill process

source

pub fn shutdown(&self)
where T::Serializer: CanSerialize<ShutdownMessage<T::Serializer>> + CanSerialize<()>,

Shuts the AbstractProcess down.

source

pub fn shutdown_timeout(&self, timeout: Option<Duration>) -> Result<(), Timeout>
where T::Serializer: CanSerialize<ShutdownMessage<T::Serializer>> + CanSerialize<()>,

Shuts the AbstractProcess down.

If a timeout is specified the function will only block for the timeout period before returning Err(Timeout).

source

pub fn send<M: 'static>(&self, message: M)
where T::Serializer: CanSerialize<M>,

Send message to the process.

source

pub fn request<R: 'static>(&self, request: R) -> T::Response
where T: RequestHandler<R>, T::Serializer: CanSerialize<R> + CanSerialize<T::Response> + CanSerialize<RequestMessage<R, T::Response, T::Serializer>>,

Make a request to the process.

source

pub fn deferred_request<R: 'static>(&self, request: R) -> T::Response
where T: DeferredRequestHandler<R>, T::Serializer: CanSerialize<R> + CanSerialize<T::Response> + CanSerialize<RequestMessage<R, T::Response, T::Serializer>>,

Make a deferred request to the process.

source

pub fn with_timeout(self, timeout: Duration) -> WithTimeout<ProcessRef<T>>

Set a timeout on the next action performed on this process.

Timeouts affect ProcessRef::shutdown, ProcessRef::request and ProcessRef::deferred_request functions.

source

pub fn with_delay(self, timeout: Duration) -> WithDelay<ProcessRef<T>>

Set a delay on the next ProcessRef::send performed on this process.

This is a non-blocking function, meaning that send is going to be performed in the background while the execution continues. The send call will return a reference to the timer allowing you to cancel it.

source§

impl<T> ProcessRef<T>
where T: Supervisor + AbstractProcess<State = SupervisorConfig<T>, Serializer = Bincode>,

source

pub fn wait_on_shutdown(&self)

Blocks until the Supervisor shuts down.

This function will not request a shutdown, just wait until someone else shuts the supervisor down.

A tagged message will be sent to the supervisor process as a request and the subscription will be registered. When the supervisor process shuts down, the subscribers will be each notified by a response message and therefore be unblocked after having received the awaited message.

source§

impl<T> ProcessRef<T>
where T: Supervisor + AbstractProcess<State = SupervisorConfig<T>, Serializer = Bincode>,

source

pub fn children( &self ) -> <<T as Supervisor>::Children as Supervisable<T>>::Processes

Trait Implementations§

source§

impl<T> Clone for ProcessRef<T>
where T: AbstractProcess,

source§

fn clone(&self) -> Self

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl<T> Debug for ProcessRef<T>
where T: AbstractProcess,

source§

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

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

impl<'de, T> Deserialize<'de> for ProcessRef<T>
where T: AbstractProcess,

source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
source§

impl<T> PartialEq for ProcessRef<T>
where T: AbstractProcess,

source§

fn eq(&self, other: &Self) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl<T> Serialize for ProcessRef<T>
where T: AbstractProcess,

source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
source§

impl<T: AbstractProcess> Copy for ProcessRef<T>

source§

impl<T> Eq for ProcessRef<T>
where T: AbstractProcess,

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> ToOwned for T
where T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

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>,

§

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.
source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,