Module std::link_monitor

Actor monitor and link handle helpers.

Import MonitorRef from this module to name the owned registration returned by monitor(actor) -> Result<MonitorRef, LinkError>. Its consuming close removes the subscription; ordinary resource cleanup closes it at scope exit. LinkError is available from the prelude; local and remote monitors share it.

Contents

Functions

Function set_partition_policy

pub fn set_partition_policy(policy: PartitionPolicy) -> bool

Select the partition-resolution policy for the current dispatch.

The policy governs how the remote send/ask failure path resolves a route that is unavailable or suspect (see PartitionPolicy). It is scoped to the current execution context — the dispatch of one actor message — so a handler can choose a policy for the remote calls it is about to make.

Returns true when the policy was recorded, false (fail-closed) when there is no execution context to record it in — i.e. the call was made outside an actor dispatch, where a partition policy has no meaning.

The tag mapping is exhaustive: every PartitionPolicy variant maps to the runtime discriminant it mirrors (execution_context.PartitionPolicy). A new variant is a compile error here until it is mapped, so the surface can never silently send an unmapped policy.

Types

Enum PartitionPolicy

Policy for resolving actor operations across network partitions.

Variants

FailFast

Return Partition immediately when the route is unavailable or suspect.

Deadline

Retry until the caller deadline, then return Timeout or Partition.

MonitorLost

Resolve monitor and supervision partitions as MonitorLost.

CrashLinked

Opt in to cross-node link and supervision fail-together behavior.

Quarantine

Stop sending to a suspect or dead peer until a fresh incarnation appears.

Struct MonitorId

Stable identifier for one monitor registration.

Fields

value: u64

Enum DownTarget

Actor identity carried by a DOWN notification.

Variants

Local(u64)

A process-local actor slot.

Remote(Location)

A complete remote actor location.

Enum DownReason

Terminal cause carried by a DOWN notification.

Variants

Stopped

The monitored actor completed a graceful stop.

Terminated

The monitored actor was forcefully terminated.

Crashed(CrashKind)

The monitored actor crashed.

MonitorLost

The remote actor became unreachable.

LocalShutdown

The local node shut down before observation completed.

Struct DownNotification

Typed payload delivered to an actor's #[on(down)] hook.

Fields

monitor: MonitorId
target: DownTarget
reason: DownReason

Struct MonitorRef

A handle to an active monitor registration.

Fields

ref_id: u64