Skip to main content

ConnectionServices

Trait ConnectionServices 

Source
pub trait ConnectionServices:
    Debug
    + Send
    + Sync {
    // Required methods
    fn publish(
        &self,
        channel: &str,
        envelope: &MessageEnvelope,
        idempotency_key: Option<&str>,
    ) -> Result<PublishOutcome, ServerError>;
    fn subscribe(
        &self,
        channel: &str,
        accepted_schemas: &[ProtocolSchemaId],
        install: Option<InboxInstall>,
    ) -> Result<ConnectionSubscription, ServerError>;
    fn unsubscribe(
        &self,
        subscription: ConnectionSubscription,
    ) -> Result<(), ServerError>;
    fn open_conversation(
        &self,
        conversation_id: u64,
        subject: &str,
    ) -> Result<ConnectionConversation, ServerError>;
    fn conversation_message(
        &self,
        conversation: &ConnectionConversation,
        envelope: &MessageEnvelope,
    ) -> Result<(), ServerError>;
    fn close_conversation(
        &self,
        conversation: ConnectionConversation,
    ) -> Result<(), ServerError>;
    fn flush_durable_state(&self) -> Result<(), ServerError>;

    // Provided methods
    fn participant_service(&self) -> Option<InstalledParticipantService> { ... }
    fn supports_channel_operations(&self) -> bool { ... }
    fn admit_channel(
        &self,
        operation: ChannelOperation,
        channel: &str,
    ) -> Result<(), ChannelAccessError> { ... }
}
Expand description

Operations that adapt wire frames to liminal library calls.

Required Methods§

Source

fn publish( &self, channel: &str, envelope: &MessageEnvelope, idempotency_key: Option<&str>, ) -> Result<PublishOutcome, ServerError>

Delegates a publish request to the liminal library.

idempotency_key, when Some, drives dedup-on-delivery: a re-publish with the same key is delivered to subscribers at most once. The returned PublishOutcome carries the genuine delivery ack.

§Errors

Returns ServerError when the liminal publish operation fails.

Source

fn subscribe( &self, channel: &str, accepted_schemas: &[ProtocolSchemaId], install: Option<InboxInstall>, ) -> Result<ConnectionSubscription, ServerError>

Delegates a subscribe request to the liminal library.

install, when Some, carries the connection’s §5 shared inbox byte budget, per-inbox fairness cap, and R3 wake notifier. The implementation MUST install it on the subscription’s inbox BEFORE the registration is published to the channel actor (i.e. before any envelope can be delivered), so no envelope is ever admitted uncharged, past the depth cap, or without a wake. Implementations with no real inbox (test stand-ins, capability-scoped profiles that refuse subscribe) may ignore it.

§Errors

Returns ServerError when the liminal subscribe operation fails.

Source

fn unsubscribe( &self, subscription: ConnectionSubscription, ) -> Result<(), ServerError>

Delegates unsubscribe to the liminal library.

§Errors

Returns ServerError when the liminal unsubscribe operation fails.

Source

fn open_conversation( &self, conversation_id: u64, subject: &str, ) -> Result<ConnectionConversation, ServerError>

Delegates conversation open to the liminal library.

§Errors

Returns ServerError when the liminal conversation open operation fails.

Source

fn conversation_message( &self, conversation: &ConnectionConversation, envelope: &MessageEnvelope, ) -> Result<(), ServerError>

Delegates a conversation message to the liminal library.

§Errors

Returns ServerError when the liminal conversation message operation fails.

Source

fn close_conversation( &self, conversation: ConnectionConversation, ) -> Result<(), ServerError>

Delegates conversation close to the liminal library.

§Errors

Returns ServerError when the liminal conversation close operation fails.

Source

fn flush_durable_state(&self) -> Result<(), ServerError>

Flushes durable channel state through the liminal library boundary.

§Errors

Returns ServerError when the liminal channel flush operation fails.

Provided Methods§

Source

fn participant_service(&self) -> Option<InstalledParticipantService>

Returns the complete participant service installed on this adapter.

None keeps participant capability disabled even when the adapter owns a durable store for unrelated channel traffic. The returned token is server-sealed and atomically carries declared semantics plus durability, making a handler-without-store activation impossible by construction.

Source

fn supports_channel_operations(&self) -> bool

Whether this adapter backs ordinary channel and conversation operations.

The default is true — the full-service adapter serves publish, subscribe, and conversation frames, so full mode is byte-for-byte unchanged. The capability-scoped worker front door overrides this to false, letting [super::apply] reject the channel/conversation frames it short-circuits on empty connection state (Unsubscribe, ConversationMessage, ConversationClose) with a typed error frame instead of silently swallowing an operation for a resource that could never have been created in this profile. Frames that always reach a service method (Publish, Subscribe, ConversationOpen) are rejected by the front door’s own method bodies and do not consult this flag.

Source

fn admit_channel( &self, operation: ChannelOperation, channel: &str, ) -> Result<(), ChannelAccessError>

Whether channel admits operation right now.

Consulted by the connection process BEFORE the operation is delegated, so a roster refusal is typed at the moment of the decision, by the component that made it, from the value it decided on. The alternative — classifying an opaque failure afterwards by re-reading the roster in the error arm — cannot tell “the roster refused this” from “something else failed while the roster happened to change”, and would put a confident wrong cause on the wire.

It does NOT replace the adapter’s own inner check. Admission here is the caller’s guard; a service method is public and callable without a frame, so it keeps its own.

The default ADMITS. An adapter with no roster has nothing to say here and its refusals travel as service errors exactly as they do today; only the roster-owning adapter overrides this. A default body is also what keeps this addition inside “minor”: a method added without one breaks every downstream implementor of a public trait.

§Errors

Returns ChannelAccessError when the roster refuses the operation.

Dyn Compatibility§

This trait is dyn compatible.

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

Implementors§