photon_runtime/runtime.rs
1//! Host-facing runtime wiring helpers (**Integrating the host**).
2
3use std::sync::Arc;
4
5use crate::{configure, Photon};
6
7/// Core runtime parts after builder (handler executor wired by integration layer).
8pub struct PhotonRuntimeParts {
9 /// Configured Photon handle.
10 pub photon: Arc<Photon>,
11}
12
13/// Build [`Photon`] with the default in-process `mem` storage adapter.
14///
15/// # Errors
16///
17/// Returns an error if the operation fails.
18pub fn build_photon_parts() -> anyhow::Result<PhotonRuntimeParts> {
19 let photon = Photon::builder()
20 .auto_registry()
21 .build()
22 .map_err(|e| anyhow::anyhow!("Photon build failed: {e}"))?;
23
24 let photon = Arc::new(photon);
25 configure((*photon).clone());
26
27 Ok(PhotonRuntimeParts { photon })
28}