Expand description
§Cranpose Capabilities
cranpose-capabilities declares the platform services, hardware demands, and file types an app uses. One Rust declaration feeds Android permissions and intent filters, Apple usage descriptions, and a generated Capabilities value for the runtime.
§Declare app capabilities
Add cranpose-capabilities as a build dependency. In app code, call cranpose::app_capabilities!() to include the generated constant. Then call emit from build.rs:
use cranpose_capabilities::{Use, declare};
fn main() {
declare(&[
Use::camera("Reads a receipt with the camera."),
Use::notifications(),
])
.opening(&["image/*", "application/pdf"])
.emit();
}emit writes OUT_DIR/cranpose_capabilities.rs with a CAPABILITIES constant. The Cranpose macro includes the file; pass the constant to AppLauncher::with_capabilities:
cranpose::app_capabilities!();
fn launcher() -> cranpose::AppLauncher {
cranpose::AppLauncher::new().with_capabilities(&CAPABILITIES)
}The build also writes package permission XML and Apple usage plist data under <workspace>/target/cranpose. Set CRANPOSE_CAPABILITIES_DIR when a platform build reads declarations from a separate output directory. The cranpose-plist binary prints Apple property-list entries from a capability declaration.
Use lists services such as camera, location, microphone, notifications, media, billing, overlay, and network. Apple camera, photo library, microphone, and location entries take a reason for the person. Demand marks hardware the app requires; other services stay optional for runtime checks.
§Links
Structs§
- Capabilities
- Everything one application asks of a device.
- Declaration
- What a build script declares, before
Declaration::emitwrites it out. - Use
- One service an application uses, with the sentence it shows if it needs one.
Enums§
- Demand
- Hardware an application cannot run without.
- Service
- Something an application uses that the device has to allow.
Functions§
- android_
manifest - The Android manifest fragment the declaration becomes.
- android_
permissions - Every Android permission the declared services need, in order and without repeats.
- android_
permissions_ up_ to - The permissions the declaration needs only up to an API level, each with that level, without repeats and leaving out any the newer list already names.
- apple_
usage - The Apple usage descriptions the declaration becomes, as a property list
to merge into an
Info.plist. - declare
- Starts a declaration with the services an application uses.
- json
- The declaration as the platform builds read it.