Skip to main content

cranpose_services/
lib.rs

1//! Multiplatform service abstractions used by Cranpose applications.
2
3#[cfg(test)]
4use cranpose_core::{location_key, Composition, MemoryApplier};
5
6pub mod http;
7pub mod theme;
8pub mod uri_handler;
9
10pub use http::{
11    default_http_client, local_http_client, map_ordered_concurrent, HttpClient, HttpClientRef,
12    HttpError, HttpFuture,
13};
14pub use theme::{
15    default_system_theme, isSystemInDarkTheme, local_system_theme, ProvideSystemTheme, SystemTheme,
16};
17pub use uri_handler::{
18    default_uri_handler, local_uri_handler, ProvideUriHandler, UriHandler, UriHandlerError,
19    UriHandlerRef,
20};
21
22/// Convenience alias used in unit tests.
23#[cfg(test)]
24pub(crate) type TestComposition = Composition<MemoryApplier>;
25
26/// Build a composition with a simple in-memory applier and run the provided closure once.
27#[cfg(test)]
28pub(crate) fn run_test_composition(build: impl FnMut()) -> TestComposition {
29    let mut composition = Composition::new(MemoryApplier::new());
30    composition
31        .render(location_key(file!(), line!(), column!()), build)
32        .expect("initial render succeeds");
33    composition
34}