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
//! Binds task scopes to navigation route lifetimes.
//!
//! The binding is deliberately one-directional: the navigation crate knows
//! nothing about tasks, and this module adds no executor or cancellation
//! engine. It couples one existing [`TaskScope`] child to one neutral
//! [`RouteLifetime`](incular_navigation::RouteLifetime), so permanent route
//! removal cancels route-associated work through the scheduler machinery
//! that already discards completions of cancelled scopes.
use ;
use TaskScope;
/// Couples one task scope to one navigation route lifetime.
///
/// [`RouteTaskBinding::bind`] creates a scope bounded by `parent` and
/// cancels it when the lifetime ends. Deactivation, keyed reorder, and
/// retained updates leave the scope alone because the lifetime survives
/// them; only permanent removal ends it. Cancelling `parent` — window
/// close, application shutdown — still cancels through the existing
/// parent-to-child ownership, and a binding made on an already-ended
/// lifetime yields an immediately cancelled scope.
///
/// Typical use: keep the binding beside the route's controller, spawn with
/// [`RuntimeSpawner::spawn_into_in`](super::tasks::RuntimeSpawner::spawn_into_in)
/// on [`Self::scope`], and let removal discard late completions instead of
/// updating a gone route.
///
/// Disposal policy: dropping the binding unregisters its removal callback,
/// so a later removal no longer cancels through this binding (detached),
/// while the scope itself follows ordinary [`TaskScope`] ownership —
/// including last-owner-drop cancellation. Retain the binding while the
/// route is mounted. Repeated removal and repeated [`TaskScope::cancel`]
/// are harmless no-ops through the idempotent lifetime and scope flags.