pub struct ModuleGraph {
pub schema_version: u32,
pub root_id: ModuleId,
pub modules: Vec<ModuleNode>,
pub canonical_hash: ModuleGraphHash,
}Expand description
The compiled module graph.
Fields§
§schema_version: u32Bumped on every breaking change to the IR shape. Today: 1.
root_id: ModuleIdAlways 0 — root module interned first (BFS from the entrypoint).
modules: Vec<ModuleNode>Dense module table indexed by ModuleId as usize.
canonical_hash: ModuleGraphHashBLAKE3 of the rkyv archive bytes. Populated by
ModuleGraph::archive_and_hash.
Implementations§
Source§impl ModuleGraph
impl ModuleGraph
Sourcepub fn new() -> Self
pub fn new() -> Self
Allocate an empty graph. Builders use Self::push_module +
Self::set_root to populate.
Sourcepub fn push_module(&mut self, node: ModuleNode) -> ModuleId
pub fn push_module(&mut self, node: ModuleNode) -> ModuleId
Add a module; return its assigned id. First module pushed gets id 0 (the root by convention; callers should ensure that’s the entrypoint module).
Sourcepub fn set_root(&mut self, id: ModuleId)
pub fn set_root(&mut self, id: ModuleId)
Set which module id is the root. Defaults to 0; override only if the build order put the root elsewhere.
Sourcepub fn from_ast_graphs(
modules: &[(String, AstGraph)],
) -> Result<Self, ModuleGraphError>
pub fn from_ast_graphs( modules: &[(String, AstGraph)], ) -> Result<Self, ModuleGraphError>
Build a ModuleGraph from a slice of (label, AstGraph) pairs.
The first pair becomes the root.
Each module is run through crate::module_compiler::compile_module
to extract its typed surface (option declarations, config setters
with slice metadata, import edges). Caller-order is preserved —
full BFS-from-root topological discovery + import-target
resolution lands when import paths get typed in a follow-up
ship (today, ImportEdge::target is the u32::MAX sentinel
for unresolved edges).
§Errors
ModuleGraphError::Archiveon rkyv failure during subsequentarchive_and_hashcalls.- Module-compiler errors are surfaced as
ModuleGraphErrorvariants — a module with an unrecognizable root shape causes the whole build to fail rather than silently emit a partial graph (operators should see the offending file).
Sourcepub fn archive_and_hash(self) -> Result<(Self, Vec<u8>), ModuleGraphError>
pub fn archive_and_hash(self) -> Result<(Self, Vec<u8>), ModuleGraphError>
Two-pass archive: serialize → BLAKE3 the bytes → stamp hash →
serialize again. Mirrors LockfileGraph::archive_and_hash and
AstGraph::archive_and_hash.
§Errors
ModuleGraphError::Archive on rkyv failure.
Trait Implementations§
Source§impl Archive for ModuleGraph
impl Archive for ModuleGraph
Source§const COPY_OPTIMIZATION: CopyOptimization<Self>
const COPY_OPTIMIZATION: CopyOptimization<Self>
serialize. Read moreSource§type Archived = ArchivedModuleGraph
type Archived = ArchivedModuleGraph
Source§type Resolver = ModuleGraphResolver
type Resolver = ModuleGraphResolver
Source§impl Clone for ModuleGraph
impl Clone for ModuleGraph
Source§fn clone(&self) -> ModuleGraph
fn clone(&self) -> ModuleGraph
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for ModuleGraph
impl Debug for ModuleGraph
Source§impl Default for ModuleGraph
impl Default for ModuleGraph
Source§impl<'de> Deserialize<'de> for ModuleGraph
impl<'de> Deserialize<'de> for ModuleGraph
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Source§impl<__D: Fallible + ?Sized> Deserialize<ModuleGraph, __D> for Archived<ModuleGraph>where
u32: Archive,
<u32 as Archive>::Archived: Deserialize<u32, __D>,
ModuleId: Archive,
<ModuleId as Archive>::Archived: Deserialize<ModuleId, __D>,
Vec<ModuleNode>: Archive,
<Vec<ModuleNode> as Archive>::Archived: Deserialize<Vec<ModuleNode>, __D>,
ModuleGraphHash: Archive,
<ModuleGraphHash as Archive>::Archived: Deserialize<ModuleGraphHash, __D>,
impl<__D: Fallible + ?Sized> Deserialize<ModuleGraph, __D> for Archived<ModuleGraph>where
u32: Archive,
<u32 as Archive>::Archived: Deserialize<u32, __D>,
ModuleId: Archive,
<ModuleId as Archive>::Archived: Deserialize<ModuleId, __D>,
Vec<ModuleNode>: Archive,
<Vec<ModuleNode> as Archive>::Archived: Deserialize<Vec<ModuleNode>, __D>,
ModuleGraphHash: Archive,
<ModuleGraphHash as Archive>::Archived: Deserialize<ModuleGraphHash, __D>,
Source§fn deserialize(
&self,
deserializer: &mut __D,
) -> Result<ModuleGraph, <__D as Fallible>::Error>
fn deserialize( &self, deserializer: &mut __D, ) -> Result<ModuleGraph, <__D as Fallible>::Error>
Source§impl PartialEq for ModuleGraph
impl PartialEq for ModuleGraph
Source§impl Serialize for ModuleGraph
impl Serialize for ModuleGraph
Source§impl<__S: Fallible + ?Sized> Serialize<__S> for ModuleGraphwhere
u32: Serialize<__S>,
ModuleId: Serialize<__S>,
Vec<ModuleNode>: Serialize<__S>,
ModuleGraphHash: Serialize<__S>,
impl<__S: Fallible + ?Sized> Serialize<__S> for ModuleGraphwhere
u32: Serialize<__S>,
ModuleId: Serialize<__S>,
Vec<ModuleNode>: Serialize<__S>,
ModuleGraphHash: Serialize<__S>,
impl StructuralPartialEq for ModuleGraph
Source§impl TataraDomain for ModuleGraph
impl TataraDomain for ModuleGraph
Source§fn compile_from_args(args: &[Sexp]) -> Result<Self>
fn compile_from_args(args: &[Sexp]) -> Result<Self>
Auto Trait Implementations§
impl Freeze for ModuleGraph
impl RefUnwindSafe for ModuleGraph
impl Send for ModuleGraph
impl Sync for ModuleGraph
impl Unpin for ModuleGraph
impl UnsafeUnpin for ModuleGraph
impl UnwindSafe for ModuleGraph
Blanket Implementations§
Source§impl<T> ArchivePointee for T
impl<T> ArchivePointee for T
Source§type ArchivedMetadata = ()
type ArchivedMetadata = ()
Source§fn pointer_metadata(
_: &<T as ArchivePointee>::ArchivedMetadata,
) -> <T as Pointee>::Metadata
fn pointer_metadata( _: &<T as ArchivePointee>::ArchivedMetadata, ) -> <T as Pointee>::Metadata
Source§impl<T> ArchiveUnsized for Twhere
T: Archive,
impl<T> ArchiveUnsized for Twhere
T: Archive,
Source§type Archived = <T as Archive>::Archived
type Archived = <T as Archive>::Archived
Archive, it may be
unsized. Read moreSource§fn archived_metadata(
&self,
) -> <<T as ArchiveUnsized>::Archived as ArchivePointee>::ArchivedMetadata
fn archived_metadata( &self, ) -> <<T as ArchiveUnsized>::Archived as ArchivePointee>::ArchivedMetadata
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
Source§impl<T> LayoutRaw for T
impl<T> LayoutRaw for T
Source§fn layout_raw(_: <T as Pointee>::Metadata) -> Result<Layout, LayoutError>
fn layout_raw(_: <T as Pointee>::Metadata) -> Result<Layout, LayoutError>
Source§impl<T, N1, N2> Niching<NichedOption<T, N1>> for N2
impl<T, N1, N2> Niching<NichedOption<T, N1>> for N2
Source§unsafe fn is_niched(niched: *const NichedOption<T, N1>) -> bool
unsafe fn is_niched(niched: *const NichedOption<T, N1>) -> bool
Source§fn resolve_niched(out: Place<NichedOption<T, N1>>)
fn resolve_niched(out: Place<NichedOption<T, N1>>)
out indicating that a T is niched.