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
// SPDX-FileCopyrightText: Copyright (c) 2026 Mike Li/Mikewolfli/Wei Li(mikewolfli@163.com)
// SPDX-License-Identifier: MIT
//! Platform capability contract negotiation.
//!
//! Determines which capabilities are available at runtime based on the
//! active platform backend and the selected `RuntimeProfile` (Full, Embedded, etc.).
//! Falls back to the backend's *family-derived* defaults when a backend does not
//! publish a contract of its own.
use crateRuntimeProfile;
use crateget_platform;
pub use crate*;
/// The contract a `Full`-profile backend gets when it publishes none.
///
/// # Why this is derived rather than hardcoded
///
/// It used to be a literal with all four flags `true`. `native_capability_contract()`
/// returns `None` for every non-`Desktop` family, so the only way to reach this
/// function was from a **non-desktop** backend — and the answer it gave that backend
/// was "you have DPI scaling, IME, accessibility and a native menu". In other words
/// the fallback was not a default, it was a claim, and it inverted the very check it
/// was backing up.
///
/// The family is the honest source: it is what `Platform::capabilities()`'s own
/// default keys off, and it is the one piece of platform knowledge a backend always
/// reports. Deriving from it makes this fallback behave exactly like an untouched
/// backend's default, which is the only defensible answer for "this backend told us
/// nothing".
/// The contract a `mini` build gets, where no backend is selectable at runtime.
///
/// `mini` is the `alloc_frugal` profile: a software surface with no OS controls, which
/// is [`PlatformFamily::Embedded`] by construction (see `platform/portable`). Deriving
/// rather than hardcoding keeps this consistent with the runtime path above.
/// Fallback contract for embedded profiles without a published backend contract.
///
/// # Why this derives rather than hardcodes
///
/// It used to return three `true`s — the same anti-pattern the *native* fallback above was fixed
/// for. `embedded_capability_contract()` returns `None` for any backend that is not the `Embedded`
/// family, so the only way to reach this function is from a backend that never claimed embedded
/// capabilities; answering "you have a fixed DPI, a low-memory mode and typed triggers" is a
/// **claim**, not a default. It is derived here from the same two facts the trait's own default
/// uses — the DPI scale factor and the backend's declared capabilities — so a backend that says
/// nothing gets exactly what an untouched backend gets.
/// Negotiate capabilities using profile-specific contracts with deterministic fallbacks.
/// Capability negotiation not available in mini mode.