sim_kernel/library/boot.rs
1use std::path::PathBuf;
2
3use crate::{ExportRecord, LibId, LibManifest, Symbol};
4
5/// A data-only library source suitable for boot receipts.
6///
7/// This mirrors the replayable variants of
8/// [`LibSource`](crate::library::LibSource). Host-constructed library objects
9/// are intentionally excluded because they contain live Rust behavior, not
10/// stable boot data.
11#[derive(Clone, Debug, PartialEq, Eq)]
12pub enum LibSourceSpec {
13 /// A catalog-resolved library symbol.
14 Symbol(Symbol),
15 /// A filesystem path.
16 Path(PathBuf),
17 /// A URL.
18 Url(String),
19 /// In-memory bytes.
20 Bytes(Vec<u8>),
21}
22
23/// A loaded dependency edge recorded in a boot receipt.
24#[derive(Clone, Debug, PartialEq, Eq)]
25pub struct LibBootDependency {
26 /// Stable id of the loaded dependency in the recorded boot session.
27 pub lib_id: LibId,
28 /// Manifest symbol of the loaded dependency.
29 pub symbol: Symbol,
30}
31
32/// The data-only receipt for one loaded library.
33#[derive(Clone, Debug, PartialEq, Eq)]
34pub struct LibBootReceipt {
35 /// Stable id assigned to the library during the recorded boot session.
36 pub lib_id: LibId,
37 /// Source requested by the caller.
38 pub requested_source: LibSourceSpec,
39 /// Source actually handed to the loader after catalog resolution.
40 pub resolved_source: LibSourceSpec,
41 /// Manifest loaded from the resolved source.
42 pub manifest: LibManifest,
43 /// Loaded dependency edges for this library.
44 pub dependencies: Vec<LibBootDependency>,
45 /// Committed export records produced by the load.
46 pub exports: Vec<ExportRecord>,
47}
48
49/// A data-only boot state for replaying a loaded registry surface.
50#[derive(Clone, Debug, Default, PartialEq, Eq)]
51pub struct RegistryBootState {
52 /// Receipts in load order.
53 pub receipts: Vec<LibBootReceipt>,
54}
55
56impl RegistryBootState {
57 /// Builds a boot state from load-order receipts.
58 pub fn new(receipts: Vec<LibBootReceipt>) -> Self {
59 Self { receipts }
60 }
61}