Skip to main content

soil_rt/
lib.rs

1//! `soil-rt` — the Soil runtime.
2//!
3//! Owns the value model, memory management (non-atomic reference
4//! counting; a runtime instance and all its values belong to one
5//! thread), derived operations, the canonical JSON bridge, and the
6//! C ABI for embedding. Everything else — `soil0`'s interpreter,
7//! compiled code, hosts — manipulates Soil values only through this
8//! crate. See `docs/plans/impls/01-soil-rt-impl.md`.
9
10pub mod capi;
11pub mod descriptor;
12pub mod descriptor_json;
13pub mod error;
14pub mod json;
15pub mod ops;
16pub mod value;
17
18pub use descriptor::{
19    FieldDesc, IgnoredDefault, Registry, Strategy, TypeBody, TypeDesc, TypeId, TypeShape,
20    VariantDesc,
21};
22pub use descriptor_json::{descriptors_to_json, load_descriptors};
23pub use error::{PanicKind, SoilError, TraceFrame};
24pub use value::{
25    debug_live_values, Closure, MapOrder, MapVal, OpaqueVal, Record, Ref, SumVal, Value,
26};
27
28/// One Soil runtime instance: the type registry and (in debug builds)
29/// the allocation accounting. No global state — embedders hold this and
30/// pass it explicitly; over the C ABI it is the `SoilRuntime*` handle.
31/// An instance and every value created under it belong to one thread.
32#[derive(Default)]
33pub struct Runtime {
34    pub registry: Registry,
35}
36
37impl Runtime {
38    pub fn new() -> Self {
39        Runtime {
40            registry: Registry::new(),
41        }
42    }
43}