Skip to main content

OutEntry

Trait OutEntry 

Source
pub trait OutEntry<M, Body = ()>: Send + Sync {
    type Wire: Send + Sync;
    type Enc: Codec;
    type Pipe: OutPipeline<Self::Wire>;
}
Expand description

What one arena entry is, stated as the mount’s choices rather than spelled out: the bound marker M, and the wired value, codec and publish path the include site gave it.

This is how a body declares its arena. It names one type parameter per marker and bounds it here, with the broker capability it needs on Wire and nothing else:

use ruststream::prelude::*;

struct Route;

impl<A, J> Handle<Order, (), Outs<(A, J)>> for Route
where
    A: OutEntry<Audit, Wire: Publisher>,
    J: OutEntry<Journal, Wire: TransactionalPublisher>,
{
    async fn handle(
        &self,
        order: &Order,
        outs: &Outs<(A, J)>,
        _ctx: &mut Context<'_>,
    ) -> Result<(), HandlerOutcome> {
        let scope = outs.get(Journal).begin().await;
        let _ = scope.is_ok();
        if outs
            .get(Audit)
            .message(&Event { id: order.id })
            .to("audit")
            .publish()
            .await
            .is_err()
        {
            return Err(HandlerOutcome::retry());
        }
        Ok(())
    }
}

The three projections are the include site’s business, so nothing the mount does reaches the body’s signature: a .transform(..) on the slot, an app-wide publish_layer, a .codec(..) override, or a different broker behind the policy all land in Pipe and Enc and leave the where clause alone.

Body is the body’s own declaration and not the mount’s, which is why it is a parameter and not a projection: it is the message set the entry’s typed publish admits, () (whatever the marker’s #[publishes(..)] dictionary holds) unless a body narrows it, and a body that publishes has to know it to name a type at all.

Outs::get hands back the entry itself, so message / begin / transaction / request and the live value’s own surface behind the entry’s Deref read exactly as they do on a spelled-out arena.

Required Associated Types§

Source

type Wire: Send + Sync

The wired live value: the bound policy’s Live form, which a body bounds with the broker capability it needs.

Source

type Enc: Codec

The codec the entry’s typed publishes encode with: the include site’s own, or the one a .codec(..) named for this slot.

Source

type Pipe: OutPipeline<Self::Wire>

The publish path every message leaving the entry travels: the app’s publish pipeline with the slot’s .transform(..) steps composed on top. It is stated over the wired value, because a transform there writes that publisher’s own per-message options.

Dyn Compatibility§

This trait is dyn compatible.

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

Implementors§

Source§

impl<M, W, E, Pipe, Body> OutEntry<M, Body> for Slot<M, W, E, Pipe, Body>
where W: Send + Sync, E: Codec, Pipe: OutPipeline<W>,

Source§

type Wire = W

Source§

type Enc = E

Source§

type Pipe = Pipe