Skip to main content

ConversationResource

Trait ConversationResource 

Source
pub trait ConversationResource: Debug + Send {
    // Required methods
    fn message(&self, envelope: &MessageEnvelope) -> Result<(), ServerError>;
    fn participant_pids(&self) -> Vec<u64>;
    fn has_detected_crash(&self) -> bool;
    fn await_crash(&self, timeout: Duration) -> Option<Instant>;
    fn receive_reply(
        &self,
        timeout: Duration,
    ) -> Result<MessageEnvelope, ServerError>;
    fn close(self: Box<Self>) -> Result<(), ServerError>;
    fn finalize(self: Box<Self>);

    // Provided methods
    fn try_receive_reply(&self) -> Option<MessageEnvelope> { ... }
    fn has_pending_reply(&self) -> bool { ... }
    fn register_reply_notifier(&self, _notifier: Arc<dyn Fn() + Send + Sync>) { ... }
}
Expand description

Marker for library conversation state owned by a single connection process.

Required Methods§

Source

fn message(&self, envelope: &MessageEnvelope) -> Result<(), ServerError>

Delegates one conversation message to the library resource.

§Errors

Returns ServerError when the liminal library rejects the conversation message.

Source

fn participant_pids(&self) -> Vec<u64>

Returns the participant PIDs linked to the supervised conversation, if any.

A trace-only conversation has no participant process and returns an empty slice; a real supervised conversation returns the linked participant PIDs.

Source

fn has_detected_crash(&self) -> bool

Returns true if the conversation has structurally detected a participant crash via the trapped linked-EXIT path (never by polling/sleeping).

This is non-blocking: it observes whether the actor’s exit notifier has already fired (the link-EXIT event landed) and falls back to the actor’s structurally-set Failed phase. It does not sample liveness.

Source

fn await_crash(&self, timeout: Duration) -> Option<Instant>

Blocks up to timeout waiting for a structural linked-EXIT crash signal, returning the Instant the EXIT was observed inside the actor’s link handler, or None if no crash is detected within the bound.

The wait is event-driven (parks on the exit notifier and is woken by the EXIT handler), not a poll loop. Used by tests to prove real detection.

Source

fn receive_reply( &self, timeout: Duration, ) -> Result<MessageEnvelope, ServerError>

Receives the next reply the participant produced for this conversation, bounded by timeout.

A real participant processes each forwarded message and delivers a reply back through the conversation; this drains that reply. A trace-only or non-replying resource times out.

§Errors

Returns ServerError when no reply arrives within timeout, the participant crashed, or the conversation is unavailable.

Source

fn close(self: Box<Self>) -> Result<(), ServerError>

Releases or finishes the library conversation resource.

§Errors

Returns ServerError when the liminal library reports a close failure.

Source

fn finalize(self: Box<Self>)

Releases the resource without requiring its backing actor to run: bounded, non-blocking, and idempotent. Connection teardown paths (and the teardown Drop backstop) MUST use this instead of Self::closeclose is a request/reply round trip into the conversation scheduler, and a teardown that waits on another scheduler being live re-creates the wedged-worker failure this repair removes. Deliberately required, not defaulted: every resource author must decide what teardown-safe release means for their live state (a defaulted no-op would let a resource that needs real cleanup leak silently). A resource with no live process behind it implements this as a plain drop(self).

Provided Methods§

Source

fn try_receive_reply(&self) -> Option<MessageEnvelope>

R1(vi)(a): non-blocking drain of one buffered participant reply, if any.

Replaces the removed in-slice BLOCKING receive_reply on the request-reply path: the connection polls this on its own slice and correlates the reply through its pending-reply table. Defaulted to None for resources with no live reply queue (trace-only / test stand-ins).

Source

fn has_pending_reply(&self) -> bool

Non-consuming reply availability query for the post-arm race barrier.

Source

fn register_reply_notifier(&self, _notifier: Arc<dyn Fn() + Send + Sync>)

R1(vi)(a): installs the reply-availability notifier (fired on the reply queue’s empty→non-empty transition and on terminal actor error), captured at conversation open. Defaulted to a no-op for resources with no reply queue.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§