pub struct AstGraph {
pub dialect: SourceDialect,
pub grammar_version: u32,
pub root_id: NodeId,
pub nodes: Vec<AstNodeForm>,
pub canonical_hash: AstGraphHash,
}Expand description
The AST graph proper. nodes[0] is always the root expression.
Fields§
§dialect: SourceDialectWhich surface dialect this graph was lowered from. Today only
Nix is implemented; Tlisp is reserved so the typed IR is
stable across the future dialect-lowering work. The IR
downstream of this field is dialect-agnostic — every
consumer (eval cache, module-graph compiler, derivation
builder) reads AstGraph without knowing which dialect
produced it. Bidirectional rendering (back to .nix /
.tlisp source text) hangs off this discriminator.
grammar_version: u32rnix grammar version the source was parsed against. Today this is locked to the bundled rnix major (0.14). Bumping is a migration boundary.
root_id: NodeIdIndex of the root expression in Self::nodes. Today, this is
always (nodes.len() - 1) as u32 because the builder is
post-order — children are pushed before their parent.
nodes: Vec<AstNodeForm>Dense node table.
canonical_hash: AstGraphHashBLAKE3 of the rkyv archive bytes. Populated by
AstGraph::archive_and_hash.
Implementations§
Source§impl AstGraph
impl AstGraph
Sourcepub fn from_source(source: &str) -> Result<Self, AstGraphError>
pub fn from_source(source: &str) -> Result<Self, AstGraphError>
Parse + canonicalize source text into a typed AST graph.
§Errors
AstGraphError::Parseif rnix can’t parse the source.AstGraphError::NoRootif the parse succeeds but produces an empty root (e.g. comments-only input).
Sourcepub fn from_tlisp_source(source: &str) -> Result<Self, AstGraphError>
pub fn from_tlisp_source(source: &str) -> Result<Self, AstGraphError>
Parse + lower a tatara-lisp source into the universal IR.
Status: typed seam only. Today this returns an Unknown-
kinded root with the source preserved verbatim so callers can
already exercise the dialect-aware downstream pipeline. The
real lowering — mapping each defast-node Lisp form to the
matching AstNodeKind variant — lands in the focused
.tlisp dialect ship.
§Errors
Always succeeds today (every input is captured as Unknown).
Future versions will return AstGraphError::Parse when the
tatara-lisp reader rejects the input.
Sourcepub fn to_nix_source(&self) -> Result<String, AstGraphError>
pub fn to_nix_source(&self) -> Result<String, AstGraphError>
Render this graph back into Nix source text.
Status: API seam only. The renderer that emits canonical
.nix syntax for every AstNodeKind variant lands in the
dialect-rendering ship.
§Errors
Always returns AstGraphError::Unimplemented today.
Sourcepub fn to_tlisp_source(&self) -> Result<String, AstGraphError>
pub fn to_tlisp_source(&self) -> Result<String, AstGraphError>
Render this graph as tatara-lisp source text.
Status: API seam only. See Self::to_nix_source.
§Errors
Always returns AstGraphError::Unimplemented today.
Sourcepub fn archive_and_hash(self) -> Result<(Self, Vec<u8>), AstGraphError>
pub fn archive_and_hash(self) -> Result<(Self, Vec<u8>), AstGraphError>
Same two-pass shape as LockfileGraph::archive_and_hash — the
hash is part of the archive, so it can’t be computed before the
archive exists.
§Errors
AstGraphError::Archive if rkyv refuses the graph shape.
Trait Implementations§
Source§impl Archive for AstGraphwhere
SourceDialect: Archive,
u32: Archive,
NodeId: Archive,
Vec<AstNodeForm>: Archive,
AstGraphHash: Archive,
impl Archive for AstGraphwhere
SourceDialect: Archive,
u32: Archive,
NodeId: Archive,
Vec<AstNodeForm>: Archive,
AstGraphHash: Archive,
Source§const COPY_OPTIMIZATION: CopyOptimization<Self>
const COPY_OPTIMIZATION: CopyOptimization<Self>
serialize. Read moreSource§type Archived = ArchivedAstGraph
type Archived = ArchivedAstGraph
Source§type Resolver = AstGraphResolver
type Resolver = AstGraphResolver
Source§impl<'de> Deserialize<'de> for AstGraph
impl<'de> Deserialize<'de> for AstGraph
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<AstGraph, __D> for Archived<AstGraph>where
SourceDialect: Archive,
<SourceDialect as Archive>::Archived: Deserialize<SourceDialect, __D>,
u32: Archive,
<u32 as Archive>::Archived: Deserialize<u32, __D>,
NodeId: Archive,
<NodeId as Archive>::Archived: Deserialize<NodeId, __D>,
Vec<AstNodeForm>: Archive,
<Vec<AstNodeForm> as Archive>::Archived: Deserialize<Vec<AstNodeForm>, __D>,
AstGraphHash: Archive,
<AstGraphHash as Archive>::Archived: Deserialize<AstGraphHash, __D>,
impl<__D: Fallible + ?Sized> Deserialize<AstGraph, __D> for Archived<AstGraph>where
SourceDialect: Archive,
<SourceDialect as Archive>::Archived: Deserialize<SourceDialect, __D>,
u32: Archive,
<u32 as Archive>::Archived: Deserialize<u32, __D>,
NodeId: Archive,
<NodeId as Archive>::Archived: Deserialize<NodeId, __D>,
Vec<AstNodeForm>: Archive,
<Vec<AstNodeForm> as Archive>::Archived: Deserialize<Vec<AstNodeForm>, __D>,
AstGraphHash: Archive,
<AstGraphHash as Archive>::Archived: Deserialize<AstGraphHash, __D>,
Source§impl<__S: Fallible + ?Sized> Serialize<__S> for AstGraphwhere
SourceDialect: Serialize<__S>,
u32: Serialize<__S>,
NodeId: Serialize<__S>,
Vec<AstNodeForm>: Serialize<__S>,
AstGraphHash: Serialize<__S>,
impl<__S: Fallible + ?Sized> Serialize<__S> for AstGraphwhere
SourceDialect: Serialize<__S>,
u32: Serialize<__S>,
NodeId: Serialize<__S>,
Vec<AstNodeForm>: Serialize<__S>,
AstGraphHash: Serialize<__S>,
impl StructuralPartialEq for AstGraph
Source§impl TataraDomain for AstGraph
impl TataraDomain for AstGraph
Source§fn compile_from_args(args: &[Sexp]) -> Result<Self>
fn compile_from_args(args: &[Sexp]) -> Result<Self>
Auto Trait Implementations§
impl Freeze for AstGraph
impl RefUnwindSafe for AstGraph
impl Send for AstGraph
impl Sync for AstGraph
impl Unpin for AstGraph
impl UnsafeUnpin for AstGraph
impl UnwindSafe for AstGraph
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.