Skip to main content

choreo_content/
lib.rs

1//! Choreographr Coordination Platform tools.
2//!
3//! This crate implements the read/write tooling for the Choreographr
4//! Coordination Platform: a Substrate runtime (`choreo-runtime`) running
5//! `pallet-content` and its companion pallets, with content payloads stored on
6//! a local IPFS node and indexed by `acuity-index`.
7//!
8//! ## Threading model
9//!
10//! The daemon stays thread-only. This crate owns a [tokio sidecar runtime]
11//! (`runtime`) used **only** to drive `subxt` (node RPC + tx submission). IPFS
12//! (`ipfs`, via `ureq`) and the indexer (`indexer`, via `tungstenite` in
13//! synchronous mode) make no use of the sidecar, so only signed chain writes
14//! and on-chain state reads go through it.
15//!
16//! ## Public surface
17//!
18//! All four modules expose [`ContentError`]-returning, blocking `execute_*`
19//! functions. The daemon registers thin `Tool` wrappers over them under the
20//! `coord` tool group.
21//!
22//! [tokio sidecar runtime]: runtime
23
24pub mod acuity_runtime;
25pub mod chain;
26pub mod config;
27pub mod encode;
28pub mod error;
29pub mod image;
30pub mod indexer;
31pub mod ipfs;
32pub mod orchestrate;
33pub mod runtime;
34
35pub use error::ContentError;
36
37/// Convenience: every module re-exports its central public types under a
38/// single `choreo_content::` path for the daemon's thin tool wrappers.
39pub mod prelude {
40    pub use crate::config::*;
41    pub use crate::encode::{
42        AccountType, ContentInput, ContentType, DecodedItem, ImageSpec, MipmapLevel, ProfileSpec,
43        derive_item_id, short_hex,
44    };
45    pub use crate::error::ContentError;
46}
47
48/// Uniffi-style init hook: build the sidecar runtime. The daemon calls this
49/// from `main()`. Idempotent.
50///
51/// # Errors
52///
53/// Fails with an opaque boxed error if the OS refuses to spawn the tokio
54/// worker threads while building the sidecar runtime (see
55/// [`runtime::init`]); subsequent calls after a successful init never fail.
56pub fn init() -> Result<(), Box<dyn std::error::Error + Send + Sync>> {
57    runtime::init()
58}