Skip to main content

ruststream_sqlx/outbox/
row.rs

1//! What the registry reads off a record, for every [`OutboxTable`].
2
3use super::dispatch::{Declared, Slot};
4use super::spec::{Declaration, OutboxTable};
5
6/// A record of an outbox table: a struct deriving [`Outbox`](derive@crate::Outbox) or
7/// implementing [`OutboxTable`].
8///
9/// The crate implements it for every [`OutboxTable`]; a service names it only as a bound.
10#[diagnostic::on_unimplemented(
11    message = "`{Self}` is not an outbox record",
12    label = "this type does not describe an outbox table",
13    note = "derive `Outbox` for `{Self}` and mark its `id`, `name` and `payload` fields, or \
14            implement `OutboxTable` for it"
15)]
16pub trait OutboxRow: OutboxTable {
17    /// Whether the record's `Retry` writes anything: `false` for the default, which leaves the
18    /// record as it is, so the subscription layer takes no connection for it.
19    #[doc(hidden)]
20    const RETRY_WRITES: bool;
21}
22
23impl<Record> OutboxRow for Record
24where
25    Record: OutboxTable,
26    <Declared<Record> as Declaration>::OwnRetry: Slot,
27{
28    const RETRY_WRITES: bool = <<Declared<Record> as Declaration>::OwnRetry as Slot>::SET;
29}