diff options
Diffstat (limited to 'tvix/store')
-rw-r--r-- | tvix/store/src/proto.rs | 16 |
1 files changed, 13 insertions, 3 deletions
diff --git a/tvix/store/src/proto.rs b/tvix/store/src/proto.rs index fc5db4446d5e..82a2d09ee5b7 100644 --- a/tvix/store/src/proto.rs +++ b/tvix/store/src/proto.rs @@ -150,9 +150,9 @@ impl PathInfo { } } -/// NamedNode is implemented for [FileNode], [DirectoryNode] and [SymlinkNode], -/// so we can ask all three for their name easily. -trait NamedNode { +/// NamedNode is implemented for [FileNode], [DirectoryNode] and [SymlinkNode] +/// and [node::Node], so we can ask all of them for the name easily. +pub trait NamedNode { fn get_name(&self) -> &str; } @@ -174,6 +174,16 @@ impl NamedNode for &SymlinkNode { } } +impl NamedNode for node::Node { + fn get_name(&self) -> &str { + match self { + node::Node::File(node_file) => &node_file.name, + node::Node::Directory(node_directory) => &node_directory.name, + node::Node::Symlink(node_symlink) => &node_symlink.name, + } + } +} + /// Accepts a name, and a mutable reference to the previous name. /// If the passed name is larger than the previous one, the reference is updated. /// If it's not, an error is returned. |