1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
//! Subscription descriptors: how a handler is bound to one broker subscription.
//!
//! A [`SubscriptionSource`] is the value a broker crate exposes as its subscriber configuration:
//! it carries everything needed to open one subscription (subject / name, consumer group,
//! durable name, delivery policy, ...) and knows how to turn that into a live [`Subscriber`]
//! against a connected broker. The default [`Name`] source covers brokers that only need a name
//! string (those implementing [`Subscribe`]); richer brokers ship their own sources.
//!
//! This is the seam the `#[subscriber(..)]` macro and the application object build on: the macro
//! takes a source (a name string or a broker config value), the runtime resolves it once after
//! the broker is connected.
use ;
use crate::;
/// A description of one subscription, resolved against a concrete broker at startup.
///
/// The runtime calls [`subscribe`] once, after [`Broker::connect`], to obtain the live
/// [`Subscriber`]. The associated [`Subscriber`](Self::Subscriber) type lives on the source rather
/// than the broker, so a single broker can offer several subscription kinds with different
/// subscriber types (for example `Redis` pub/sub versus streams).
///
/// [`subscribe`]: Self::subscribe
///
/// # Examples
///
/// ```
/// use ruststream::{Broker, SubscriptionSource};
///
/// async fn open<B, S>(source: S, broker: &B) -> Result<S::Subscriber, B::Error>
/// where
/// B: Broker,
/// S: SubscriptionSource<B>,
/// {
/// source.subscribe(broker).await
/// }
/// ```
/// The default [`SubscriptionSource`]: subscribe by name string via the [`Subscribe`] capability.
///
/// Produced by `#[subscriber("name")]` and usable directly with any broker implementing
/// [`Subscribe`].
///
/// # Examples
///
/// ```
/// use ruststream::{Broker, Subscribe, SubscriptionSource, Name};
///
/// async fn open<B: Subscribe>(broker: &B) -> Result<B::Subscriber, B::Error> {
/// Name::new("orders").subscribe(broker).await
/// }
/// ```
;