@@ -294,17 +294,17 @@ impl RegisteredPackage {
294294#[ derive( Debug , Clone ) ]
295295pub struct Node {
296296 /// The node kind.
297- pub kind : NodeKind ,
297+ kind : NodeKind ,
298298 /// The package associated with the node, if any.
299- pub package : Option < PackageId > ,
299+ package : Option < PackageId > ,
300300 /// The item kind of the node.
301- pub item_kind : ItemKind ,
301+ item_kind : ItemKind ,
302302 /// The optional name to associate with the node.
303303 ///
304304 /// When the graph is encoded, node names are recorded in a `names` custom section.
305- pub name : Option < String > ,
305+ name : Option < String > ,
306306 /// The name to use for exporting the node.
307- pub export : Option < String > ,
307+ export : Option < String > ,
308308}
309309
310310impl Node {
@@ -318,13 +318,49 @@ impl Node {
318318 }
319319 }
320320
321- fn import_name ( & self ) -> Option < & str > {
321+ /// Gets the kind of the node.
322+ pub fn kind ( & self ) -> & NodeKind {
323+ & self . kind
324+ }
325+
326+ /// Gets the package id associated with the node.
327+ ///
328+ /// Returns `None` if the node is not directly associated with a package.
329+ pub fn package ( & self ) -> Option < PackageId > {
330+ self . package
331+ }
332+
333+ /// Gets the item kind of the node.
334+ pub fn item_kind ( & self ) -> ItemKind {
335+ self . item_kind
336+ }
337+
338+ /// Gets the name of the node.
339+ ///
340+ /// Node names are encoded in a `names` custom section.
341+ ///
342+ /// Returns `None` if the node is unnamed.
343+ pub fn name ( & self ) -> Option < & str > {
344+ self . name . as_deref ( )
345+ }
346+
347+ /// Gets the import name of the node.
348+ ///
349+ /// Returns `Some` if the node is an import or `None` if the node is not an import.
350+ pub fn import_name ( & self ) -> Option < & str > {
322351 match & self . kind {
323352 NodeKind :: Import ( name) => Some ( name) ,
324353 _ => None ,
325354 }
326355 }
327356
357+ /// Gets the export name of the node.
358+ ///
359+ /// Returns `None` if the node is not exported.
360+ pub fn export_name ( & self ) -> Option < & str > {
361+ self . export . as_deref ( )
362+ }
363+
328364 fn add_satisfied_arg ( & mut self , index : usize ) {
329365 match & mut self . kind {
330366 NodeKind :: Instantiation ( satisfied) => {
@@ -532,7 +568,10 @@ impl CompositionGraph {
532568 let key = entry. package . as_ref ( ) . unwrap ( ) . key ( ) ;
533569 log:: debug!( "unregistering package `{key}` with the graph" ) ;
534570 let prev = self . package_map . remove ( & key as & dyn BorrowedKey ) ;
535- assert ! ( prev. is_some( ) ) ;
571+ assert ! (
572+ prev. is_some( ) ,
573+ "package should exist in the package map (this is a bug)"
574+ ) ;
536575
537576 // Finally free the package
538577 * entry = RegisteredPackage :: new ( entry. generation . wrapping_add ( 1 ) ) ;
0 commit comments