Device capabilities (parts)
A part exposes a platform capability without a UI, such as battery status, storage, or sensors. It provides a shared Rust API with an implementation selected at compile time for the target operating system. Parts are Cargo dependencies and require no runtime plugin registry.
The UI snippets use generated res::str accessors from an app’s Fluent catalog; see the
example messages and catalog setup.
The catalog
| Crate | What it does | Reference |
|---|---|---|
day-part-battery | charge level and charging state | battery |
day-part-clipboard | read/write the system clipboard (text) | clipboard |
day-part-prefs | small key-value preference storage in the platform’s conventional location | prefs |
day-part-fs | app-local file storage: read, write, remove, list (sync and async) | fs |
day-part-local-notify | local notifications: post now or schedule, channels, tap-to-route | notify |
day-part-network | connectivity status | network |
day-part-deviceinfo | device model, OS version | deviceinfo |
day-part-sensors | accelerometer and friends, as a live stream | sensors |
day-part-http | HTTP through each platform’s networking stack | http |
day-part-permissions | ask the OS for the camera, location, notifications … and declare them at build time | permissions |
day-part-location | the device’s position, once or as a live stream | location |
day-part-haptics | haptic feedback | haptics |
day-part-sound | sound effects | sound |
day-part-wakelock | keeping the screen on | wakelock |
day-part-speech | text to speech through each platform’s speech API; in a separate repository | day-part-speech |
Select an API by its completion model
| Need | Entry point and result | Constraint |
|---|---|---|
| Current battery reading | day_part_battery::status() -> Option<BatteryStatus> | Absence can mean no battery/API; inspect the returned fields |
| Small preference | day::prefs::get(&str) -> Option<String>; set(&str, &str) -> bool | Synchronous; the default facade feature supplies it; false/None can include failure |
| File data | day_part_fs::read_future(&str) | Await a result; native blocking forms must stay off the UI thread |
| HTTP response | day_part_http::fetch_future(Request) | Check transport errors and HTTP status separately |
| Permission | day_part_permissions::status_future(Permission) | Await authoritative status; a grant does not establish hardware availability |
| Notification | Notification::post() -> Result<NotifId, NotifyError> | Consent and channel setup are separate; success does not establish delivery |
A part is a crate category, not a shared Part trait. There is no universal error or support
contract: check each part’s capabilities, is_supported, optional value, or error result.
OS selection often uses conditional compilation; some parts also depend on a live host bridge.
Enabling a UI backend feature does not prove that all parts are available.
For callbacks requiring Send, pass result data through a Setter. For futures awaited inside
day::task, update signals and format generated localized messages on the UI thread. Keep task
and scope lifetimes explicit. See async ownership.
Complete tasks
Use the compile-designated HTTP, storage, permission, and notification recipes. Clipboard’s synchronous text helpers cannot express browser async permission behavior; consult the clipboard reference for its asynchronous content API.
Implement a part
A part can contribute native source, dependencies, and permissions through Cargo metadata. Follow the part tutorial, extension model, and bridge contract for implementation details. Inline bridge language arms are contributor material, not an additional app-facing Part interface.
Source review: part crates and facade feature gates, 2026-10-22. The speech part is an external project; its implementation and current compatibility were not verified in this repository-only review.