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
//! Ids handed out under a lock, to tell one thing apart from another that replaced it.
//!
//! Two shapes use this, and the difference lives in the caller, not in the id:
//!
//! - a *generation*, compared against [`IdGenerator::latest`] to tell whether something built with
//! the lock released is still the current one — see
//! [`SharedDisposal`](crate::disposable::shared_disposal::SharedDisposal) and
//! [`Switch`](crate::operators::combining::switch::Switch);
//! - a *key*, identifying an entry of a collection — see
//! [`MergeAll`](crate::operators::combining::merge_all::MergeAll) and
//! [`PublishSubject`](crate::subject::publish_subject::PublishSubject).
//!
//! An [`Id`] can only come from an [`IdGenerator`], which never hands the same one out twice, so a
//! holder of an id cannot forge one that collides with a later value.
/// Hands out an [`Id`] that is never equal to any it handed out before.
///
/// It carries no lock of its own: it lives inside state that is already guarded, and
/// [`next_id`](Self::next_id) takes `&mut self`.
;
/// An id handed out by an [`IdGenerator`].
///
/// There is deliberately no `Default`: an id can only be obtained from a generator, so it can
/// never accidentally equal the value a generator starts from.
;