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
use ;
use SmolStr;
use Borrow;
use ;
/// New type representing a unique `String` identifier for a stream that has been subscribed to.
/// This is used to identify data structures received over the socket.
///
/// For example, `Barter-Data` uses this identifier to associate received data structures from the
/// execution with the original `Barter-Data` `Subscription` that was actioned over the socket.
///
/// Note: Each execution will require the use of different `String` identifiers depending on the
/// data structures they send.
///
/// eg/ [`SubscriptionId`] of an `FtxTrade` is "{BASE}/{QUOTE}" (ie/ market).
/// eg/ [`SubscriptionId`] of a `BinanceTrade` is `"@trade|BTCUSDT"` (ie/ channel|MARKET).
;
/// Borrow a [`SubscriptionId`] as a `&str` so an instrument map keyed on [`SubscriptionId`]
/// can be queried with a borrowed key (e.g. `Map::find("@kline_1m|BTCUSDT")`) without
/// allocating an owned [`SubscriptionId`] per lookup.
///
/// Soundness: the `Hash`, `Eq`, and `Ord` impls of [`SubscriptionId`] must agree with those of
/// `str` for `Borrow` to be valid. [`SubscriptionId`] derives all three over its single inner
/// [`SmolStr`] field, and `SmolStr`'s `Hash`/`Eq`/`Ord` delegate to its string contents — so a
/// `SubscriptionId` hashes, compares, and orders identically to the `str` it borrows.