Expand description
§Cranpose services
cranpose-services defines platform service contracts for Cranpose applications. The crate groups APIs for HTTP, files and folders, URI handlers, audio and media, camera, image pickers, haptics, accessibility, device and power information, app updates, purchases, navigation, preferences, and shared content.
Most applications use these APIs through the cranpose facade. Add cranpose-services directly when an application provides a custom backend or needs a service contract outside the facade. Platform adapters register implementations through each module’s set_platform_* function. Composition-local services use local_* functions and Provide* composables; process-wide services use plain functions.
§Example: read purchase state
Configure product IDs at startup, then read the current snapshot and react to store updates from app code:
use cranpose_services::purchases;
fn configure_store() {
purchases::configure(&["com.example.pro"]);
}
fn pro_is_owned() -> bool {
purchases::store_state().owns("com.example.pro")
}
fn current_store_phase() -> purchases::StorePhase {
purchases::store_state().phase
}Purchase events arrive asynchronously through rememberPurchaseEvents or take_event. Store platform setup in the adapter. See the purchases API.
§Features and platform adapters
The default feature set is empty. Select only the host integrations the application uses:
| Feature | Integration |
|---|---|
http-native | Native HTTP client with platform TLS support |
web-http | Browser HTTP client |
file-picker-native | Native desktop file and folder picker |
file-picker-web | Browser file and folder picker |
uri-native, uri-android, uri-web | URI open requests for each host |
preferences-web | Browser local storage |
system-theme, system-theme-web | Native or browser theme detection |
notifier-native | Desktop notifications through host commands |
Android and iOS file pickers register through the cranpose platform backends. The cranpose facade selects service features for its platform; app authors can also choose features directly for custom hosts. cranpose-audio implements short sound playback, cranpose-media implements native long-form playback, and cranpose-capabilities writes app permission declarations.
§Links
Re-exports§
pub use accessibility_options::AccessibilityOptions;pub use accessibility_options::ProvideAccessibilityOptions;pub use accessibility_options::local_accessibility_options;pub use accessibility_options::platform_accessibility_options;pub use accessibility_options::set_platform_accessibility_options;pub use accessibility_state::AccessibilityState;pub use accessibility_state::ProvideAccessibilityState;pub use accessibility_state::local_accessibility_state;pub use accessibility_state::platform_accessibility_state;pub use accessibility_state::set_platform_accessibility_state;pub use app_info::AppInfo;pub use app_info::AppInfoRef;pub use app_info::app_info;pub use app_info::build_version;pub use app_info::clear_platform_app_info;pub use app_info::set_platform_app_info;pub use app_info::version_name;pub use app_update::AppUpdateCapabilities;pub use app_update::AppUpdateError;pub use app_update::AppUpdateObserver;pub use app_update::AppUpdateStatus;pub use app_update::AppUpdater;pub use app_update::AppUpdaterRef;pub use app_update::DigestAlgorithm;pub use app_update::DigestVerifier;pub use app_update::GitHubReleaseUpdate;pub use app_update::PackageDigest;pub use app_update::UpdatePackage;pub use app_update::app_update_capabilities;pub use app_update::app_update_checks_supported;pub use app_update::app_update_status;pub use app_update::app_updates_supported;pub use app_update::check_for_app_update;pub use app_update::clear_platform_app_updater;pub use app_update::install_app_update;pub use app_update::observe_app_update_status;pub use app_update::set_app_update_status;pub use app_update::set_platform_app_updater;pub use app_update::sha256_hex;pub use app_update::verify_package;pub use async_io::ChunkChannel;pub use async_io::ChunkNext;pub use async_io::ChunkStream;pub use async_io::MAX_PENDING_CHUNKS;pub use async_io::Signal;pub use async_io::SignalWait;pub use audio::AudioBus;pub use audio::AudioClip;pub use audio::AudioError;pub use audio::AudioPlayer;pub use audio::AudioPlayerRef;pub use audio::NoopAudioPlayer;pub use audio::PlaybackParams;pub use audio::ProvideAudio;pub use audio::SoundBank;pub use audio::SoundBankEntry;pub use audio::SoundBankFailure;pub use audio::SoundId;pub use audio::SoundSpec;pub use audio::VoiceId;pub use audio::clear_platform_audio;pub use audio::default_audio;pub use audio::local_audio;pub use audio::rememberSoundBank;pub use audio::set_platform_audio;pub use background::BackgroundActivity;pub use background::BackgroundActivityRef;pub use background::BackgroundWorkLease;pub use background::acquire_background_work;pub use background::background_active;pub use background::background_activity;pub use background::clear_platform_background_activity;pub use background::set_platform_background_activity;pub use bundled_assets::BundledAssetEntry;pub use bundled_assets::BundledAssetInstallOutcome;pub use bundled_assets::BundledAssetInstallSpec;pub use bundled_assets::install_bundled_asset_set;pub use bundled_assets::BundledAssetError;pub use bundled_assets::BundledAssetReader;pub use bundled_assets::BundledAssets;pub use bundled_assets::BundledAssetsRef;pub use bundled_assets::StreamingAssetReader;pub use bundled_assets::bundled_assets;pub use bundled_assets::clear_platform_bundled_assets;pub use bundled_assets::set_platform_bundled_assets;pub use camera::Camera;pub use camera::CameraError;pub use camera::CameraFrame;pub use camera::CameraLens;pub use camera::CameraLenses;pub use camera::CameraObserver;pub use camera::CameraRef;pub use camera::CameraState;pub use camera::CameraStill;pub use camera::FlashMode;pub use camera::FrameFormat;pub use camera::LensFacing;pub use camera::UprightRgba;pub use camera::camera;pub use camera::camera_lenses;pub use camera::camera_state;pub use camera::camera_supported;pub use camera::capture_camera_still;pub use camera::clear_platform_camera;pub use camera::dropped_camera_frames;pub use camera::latest_camera_frame;pub use camera::observe_camera_frames;pub use camera::observe_camera_lenses;pub use camera::observe_camera_state;pub use camera::observe_camera_stills;pub use camera::publish_camera_frame;pub use camera::publish_camera_lenses;pub use camera::publish_camera_state;pub use camera::publish_camera_still;pub use camera::record_dropped_camera_frame;pub use camera::rememberCameraFrames;pub use camera::rememberCameraLenses;pub use camera::rememberCameraState;pub use camera::rememberCameraStills;pub use camera::request_camera_still;pub use camera::set_platform_camera;pub use camera::start_camera;pub use camera::stop_camera;pub use content::BytesContent;pub use content::Content;pub use content::ContentChannel;pub use content::ContentEntry;pub use content::ContentError;pub use content::ContentFolder;pub use content::ContentFolderRef;pub use content::ContentFuture;pub use content::ContentHandle;pub use content::ContentMetadata;pub use content::ContentReader;pub use content::ContentReaderRef;pub use content::ContentResolver;pub use content::ContentResolverRef;pub use content::ContentSink;pub use content::ContentSinkRef;pub use content::ContentStream;pub use content::ContentStreamRef;pub use content::DEFAULT_CHUNK_LEN;pub use content::ReadyFolder;pub use content::clear_platform_content_resolver;pub use content::collect_stream;pub use content::drain_reader;pub use content::folder_files;pub use content::percent_decode;pub use content::percent_decode_lossy;pub use content::resolve_content;pub use content::set_platform_content_resolver;pub use content::write_all;pub use content::FileContent;pub use content::FileFolder;pub use content::FileSink;pub use content::file_content;pub use content::file_folder;pub use device_info::DeviceInfo;pub use device_info::DeviceInfoRef;pub use device_info::clear_platform_device_info;pub use device_info::device_info;pub use device_info::release_free_memory;pub use device_info::set_platform_device_info;pub use file_picker::FileFilter;pub use file_picker::FilePicker;pub use file_picker::FilePickerError;pub use file_picker::FilePickerOptions;pub use file_picker::FilePickerRef;pub use file_picker::PickerFuture;pub use file_picker::ProvideFilePicker;pub use file_picker::SaveDocumentRequest;pub use file_picker::clear_platform_file_picker;pub use file_picker::default_file_picker;pub use file_picker::local_file_picker;pub use file_picker::set_platform_file_picker;pub use github_release_updater::GitHubAppUpdater;pub use haptics::HapticEffect;pub use haptics::HapticError;pub use haptics::HapticFeedback;pub use haptics::HapticPattern;pub use haptics::Haptics;pub use haptics::HapticsRef;pub use haptics::ProvideHaptics;pub use haptics::clear_platform_haptics;pub use haptics::default_haptics;pub use haptics::local_haptics;pub use haptics::set_platform_haptics;pub use host::DEFAULT_DURABLE_SAVE_DEADLINE;pub use host::DurableSaveEffect;pub use host::DurableSaveOutcome;pub use host::DurableSaveRegistration;pub use host::HostController;pub use host::HostControllerRef;pub use host::LifecycleEvent;pub use host::LifecycleObserver;pub use host::LifecycleState;pub use host::PlatformDirectories;pub use host::PlatformDirectoryError;pub use host::ProvideLifecycle;pub use host::advance_lifecycle;pub use host::application_directories;pub use host::application_id;pub use host::background_app;pub use host::clear_application_id;pub use host::clear_host_controller;pub use host::current_lifecycle_state;pub use host::dispatch_lifecycle;pub use host::dispatch_lifecycle_state;pub use host::exit_app;pub use host::host_controller;pub use host::local_lifecycle_state;pub use host::observe_lifecycle;pub use host::register_durable_save;pub use host::rememberLifecycleEvents;pub use host::rememberLifecycleState;pub use host::set_application_id;pub use host::set_host_controller;pub use host::set_keep_screen_on;pub use host::window_lifecycle_state;pub use host::durable_save_deadline;pub use host::run_durable_saves;pub use host_messages::HostMessage;pub use host_messages::HostMessageObserver;pub use host_messages::clear_host_messages;pub use host_messages::clear_host_outbox;pub use host_messages::install_host_outbox;pub use host_messages::observe_host_messages;pub use host_messages::publish_host_message;pub use host_messages::rememberHostMessages;pub use host_messages::send_to_host;pub use host_surface::HostSurface;pub use host_surface::HostSurfaceObserver;pub use host_surface::HostSurfaceRef;pub use host_surface::HostSurfaceSize;pub use host_surface::ResizeRefused;pub use host_surface::clear_platform_host_surface;pub use host_surface::host_surface;pub use host_surface::host_surface_size;pub use host_surface::observe_host_surface_size;pub use host_surface::publish_host_surface_size;pub use host_surface::rememberHostSurfaceSize;pub use host_surface::request_host_surface_size;pub use host_surface::set_platform_host_surface;pub use http::BytesBody;pub use http::HttpBody;pub use http::HttpBodyRef;pub use http::HttpClient;pub use http::HttpClientRef;pub use http::HttpControl;pub use http::HttpError;pub use http::HttpFuture;pub use http::HttpMethod;pub use http::HttpProgress;pub use http::HttpRequest;pub use http::HttpResponse;pub use http::ProgressHandler;pub use http::StubAnswer;pub use http::StubHttpClient;pub use http::default_http_client;pub use http::http_body_ref;pub use http::local_http_client;pub use http::map_ordered_concurrent;pub use image_picker::IMAGE_EXTENSIONS;pub use image_picker::ImagePicker;pub use image_picker::ImagePickerError;pub use image_picker::ImagePickerRef;pub use image_picker::ImageSource;pub use image_picker::ProvideImagePicker;pub use image_picker::clear_platform_image_picker;pub use image_picker::default_image_picker;pub use image_picker::local_image_picker;pub use image_picker::set_platform_image_picker;pub use incoming_share::IncomingContent;pub use incoming_share::IncomingContentObserver;pub use incoming_share::IncomingSource;pub use incoming_share::clear_incoming_content;pub use incoming_share::observe_incoming_content;pub use incoming_share::publish_incoming_content;pub use incoming_share::rememberIncomingContent;pub use launch_args::LaunchArgValue;pub use launch_args::LaunchArgs;pub use launch_args::LaunchArgsRef;pub use launch_args::ProvideLaunchArgs;pub use launch_args::clear_platform_launch_args;pub use launch_args::is_debuggable;pub use launch_args::isDebuggable;pub use launch_args::launch_args;pub use launch_args::launch_args_from_command_line;pub use launch_args::local_launch_args;pub use launch_args::set_platform_launch_args;pub use launcher::LauncherResult;pub use launcher::OpenFileLauncher;pub use launcher::OpenFilesLauncher;pub use launcher::OpenFolderLauncher;pub use launcher::SaveDocumentLauncher;pub use launcher::WritableFolderLauncher;pub use launcher::clear_launcher_state;pub use launcher::rememberOpenFileLauncher;pub use launcher::rememberOpenFilesLauncher;pub use launcher::rememberOpenFolderLauncher;pub use launcher::rememberSaveDocumentLauncher;pub use launcher::rememberWritableFolderLauncher;pub use media::AudioFocus;pub use media::DUCKED_GAIN;pub use media::EqualizerBand;pub use media::EqualizerSettings;pub use media::MediaArtwork;pub use media::MediaCapabilities;pub use media::MediaCommand;pub use media::MediaError;pub use media::MediaItem;pub use media::MediaMetadata;pub use media::MediaObserver;pub use media::MediaPlayer;pub use media::MediaPlayerRef;pub use media::MediaSamples;pub use media::MediaSourceHandle;pub use media::MediaSourceOpener;pub use media::MediaSourceOpenerRef;pub use media::OCTAVE_BAND_CENTERS_HZ;pub use media::PlaybackProgress;pub use media::PlaybackState;pub use media::audio_focus;pub use media::clear_platform_media_player;pub use media::clear_platform_media_source_opener;pub use media::current_media_item;pub use media::dropped_media_samples;pub use media::latest_media_samples;pub use media::media_capabilities;pub use media::media_equalizer;pub use media::media_equalizer_bands;pub use media::media_playback_supported;pub use media::media_player;pub use media::media_volume;pub use media::observe_audio_focus;pub use media::observe_media_commands;pub use media::observe_media_samples;pub use media::observe_playback_progress;pub use media::observe_playback_state;pub use media::octave_equalizer_bands;pub use media::open_media;pub use media::open_media_source;pub use media::path_from_uri;pub use media::pause_media;pub use media::play_media;pub use media::playback_progress;pub use media::playback_state;pub use media::probe_media_duration;pub use media::publish_audio_focus;pub use media::publish_media_command;pub use media::publish_media_samples;pub use media::publish_playback_progress;pub use media::publish_playback_state;pub use media::record_dropped_media_samples;pub use media::rememberAudioFocus;pub use media::rememberMediaCommands;pub use media::rememberMediaSamples;pub use media::rememberPlaybackProgress;pub use media::rememberPlaybackState;pub use media::seek_media;pub use media::seek_media_fraction;pub use media::set_media_analysis_enabled;pub use media::set_media_balance;pub use media::set_media_equalizer;pub use media::set_media_looping;pub use media::set_media_metadata;pub use media::set_media_speed;pub use media::set_media_volume;pub use media::set_platform_media_player;pub use media::set_platform_media_source_opener;pub use media::stop_media;pub use media::toggle_media;pub use media::uri_for_path;pub use memory_pressure::MemoryPressure;pub use memory_pressure::MemoryPressureObserver;pub use memory_pressure::observe_memory_pressure;pub use memory_pressure::publish_memory_pressure;pub use memory_pressure::rememberMemoryPressure;pub use navigation::BackHandler;pub use navigation::BackRequestObserver;pub use navigation::back_interception_enabled;pub use navigation::exit_requested;pub use navigation::observe_back_requests;pub use navigation::push_back_request;pub use navigation::request_exit;pub use navigation::set_back_interception;pub use navigation::take_back_requests;pub use navigation::take_exit_request;pub use network_status::NetworkMonitor;pub use network_status::NetworkMonitorRef;pub use network_status::NetworkStatus;pub use network_status::clear_platform_network_monitor;pub use network_status::network_monitor;pub use network_status::network_status;pub use network_status::set_platform_network_monitor;pub use notifier::Notifier;pub use notifier::NotifierRef;pub use notifier::NotifyRequest;pub use notifier::ProvideNotifier;pub use notifier::clear_platform_notifier;pub use notifier::default_notifier;pub use notifier::local_notifier;pub use notifier::push_notification_deeplink;pub use notifier::set_platform_notifier;pub use notifier::take_notification_deeplink;pub use peer::ByteSource;pub use peer::BytesSource;pub use peer::FetchResult;pub use peer::PeerError;pub use peer::PeerServer;pub use peer::SourceResolver;pub use peer::content_length;pub use peer::fetch_range;pub use peer::fetch_to_writer;pub use power::BatteryStatus;pub use power::PowerCapabilities;pub use power::PowerMonitor;pub use power::PowerMonitorRef;pub use power::PowerObserverRegistration;pub use power::PowerReading;pub use power::PowerState;pub use power::ThermalState;pub use power::clear_platform_power_monitor;pub use power::observe_power_state;pub use power::power_capabilities;pub use power::power_monitor;pub use power::power_state;pub use power::publish_power_state;pub use power::rememberPowerState;pub use power::set_platform_power_monitor;pub use preferences::FilePreferences;pub use preferences::MemoryPreferences;pub use preferences::PreferencesError;pub use preferences::PreferencesRef;pub use preferences::PreferencesStore;pub use preferences::Saver;pub use preferences::clear_platform_preferences;pub use preferences::preferences;pub use preferences::rememberSaveable;pub use preferences::set_platform_preferences;pub use purchases::Product;pub use purchases::PurchaseEvent;pub use purchases::Purchases;pub use purchases::PurchasesRef;pub use purchases::StoreObserver;pub use purchases::StorePhase;pub use purchases::StoreState;pub use purchases::clear_platform_purchases;pub use purchases::note_store_news;pub use purchases::observe_store_news;pub use purchases::purchases;pub use purchases::rememberPurchaseEvents;pub use purchases::rememberStoreState;pub use purchases::set_platform_purchases;pub use purchases::store_available;pub use purchases::store_state;pub use theme::ProvideSystemTheme;pub use theme::SystemTheme;pub use theme::clear_platform_system_theme;pub use theme::default_system_theme;pub use theme::isSystemInDarkTheme;pub use theme::local_system_theme;pub use theme::set_platform_system_theme;pub use uri_handler::ProvideUriHandler;pub use uri_handler::UriHandler;pub use uri_handler::UriHandlerError;pub use uri_handler::UriHandlerRef;pub use uri_handler::clear_platform_uri_handler;pub use uri_handler::default_uri_handler;pub use uri_handler::local_uri_handler;pub use uri_handler::set_platform_uri_handler;pub use writable_folder::FolderEntry;pub use writable_folder::FolderError;pub use writable_folder::FolderReader;pub use writable_folder::FolderWriter;pub use writable_folder::WritableFolderStore;pub use writable_folder::WritableFolderStoreRef;pub use writable_folder::open_writable_folder;pub use writable_folder::set_writable_folder_store_factory;
Modules§
- accessibility_
options - The display options a person set in the system’s accessibility settings: larger text, less motion, less transparency, more contrast, bold text, inverted colors. The framework applies them on its own; an app reads them for what it draws itself.
- accessibility_
state - What the platform says about the assistive technology in use, for an app that speaks guidance, slows an automatic step down or drops a gesture-only path while a screen reader is on.
- app_
info - How the platform packaged this app: the version a user is shown, and the build version a store orders releases by.
- app_
update - Typed application update discovery, verification, and platform installation.
- async_
io - Waking a future from another thread.
- audio
- Sound effects and music — the audio analogue of
haptics. - background
- Background execution: ask the OS to keep running briefly after the app is backgrounded, so in-flight work (e.g. draining a recognition queue) can finish instead of being suspended immediately.
- bundled_
assets - Read-only assets packaged with the application.
- camera
- The live camera: what it is doing, the frames it is producing, and the stills it takes.
- content
- Streaming content: the single shape every byte source hands the application.
- device_
info - What the device has, and what this process is using of it.
- file_
picker - Native, cross-platform file, folder and document choosers.
- github_
release_ updater - A portable
AppUpdaterthat discovers a newer release from a GitHub repository’s release feed. - haptics
- Haptic feedback — the framework analogue of Jetpack’s
LocalHapticFeedback. - host
- Framework-owned application-host state and controls.
- host_
messages - Messages between the application and the program embedding it.
- host_
surface - The surface the host gives the application, and what the application may ask of it.
- http
- image_
picker - Photo/image picker: choose a single image from the user’s photo library.
- incoming_
share - Content another application shares into this one.
- launch_
args - Launch arguments — the typed parameters the app was started with.
- launcher
- Composition-owned launchers for the system choosers.
- media
- Media playback: one item at a time, observable rather than polled.
- memory_
pressure - Memory pressure the platform reports for this process.
- navigation
- System “back” navigation requests.
- network_
status - Network status (connectivity + whether the connection is metered). Apps use it to defer or confirm large transfers on cellular/metered links.
- notifier
- Local notifications: ask permission and post user-visible notifications.
- peer
- Local-network peer streaming for Cranpose apps.
- power
- Device power and thermal state: observable, capability-aware, and explicit about what this platform cannot answer.
- preferences
- Small durable key/value storage, and the composition state built on it.
- purchases
- In-app purchases: products, prices and owned entitlements.
- share_
sheet - System share sheet: hand a file (and optional text) to the OS share UI so the user can send it to another app.
- theme
- uri_
handler - writable_
folder - Cross-platform access to a user-chosen writable folder.
Functions§
- windowless_
command - A
Commandfor a helper program an application runs behind its window, such asreg,powershellornotify-send.