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

CrateWhat it doesReference
day-part-batterycharge level and charging statebattery
day-part-clipboardread/write the system clipboard (text)clipboard
day-part-prefssmall key-value preference storage in the platform’s conventional locationprefs
day-part-fsapp-local file storage: read, write, remove, list (sync and async)fs
day-part-local-notifylocal notifications: post now or schedule, channels, tap-to-routenotify
day-part-networkconnectivity statusnetwork
day-part-deviceinfodevice model, OS versiondeviceinfo
day-part-sensorsaccelerometer and friends, as a live streamsensors
day-part-httpHTTP through each platform’s networking stackhttp
day-part-permissionsask the OS for the camera, location, notifications … and declare them at build timepermissions
day-part-locationthe device’s position, once or as a live streamlocation
day-part-hapticshaptic feedbackhaptics
day-part-soundsound effectssound
day-part-wakelockkeeping the screen onwakelock
day-part-speechtext to speech through each platform’s speech API; in a separate repositoryday-part-speech

Select an API by its completion model

NeedEntry point and resultConstraint
Current battery readingday_part_battery::status() -> Option<BatteryStatus>Absence can mean no battery/API; inspect the returned fields
Small preferenceday::prefs::get(&str) -> Option<String>; set(&str, &str) -> boolSynchronous; the default facade feature supplies it; false/None can include failure
File dataday_part_fs::read_future(&str)Await a result; native blocking forms must stay off the UI thread
HTTP responseday_part_http::fetch_future(Request)Check transport errors and HTTP status separately
Permissionday_part_permissions::status_future(Permission)Await authoritative status; a grant does not establish hardware availability
NotificationNotification::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.