refactor(tvix/castore): drop {Directory,File,Symlink}Node

Add a `SymlinkTarget` type to represent validated symlink targets.
With this, no invalid states are representable, so we can make `Node` be
just an enum of all three kind of types, and allow access to these
fields directly.

Change-Id: I20bdd480c8d5e64a827649f303c97023b7e390f2
Reviewed-on: https://cl.tvl.fyi/c/depot/+/12216
Reviewed-by: benjaminedwardwebb <benjaminedwardwebb@gmail.com>
Autosubmit: flokli <flokli@flokli.de>
Reviewed-by: Connor Brewster <cbrewster@hey.com>
Tested-by: BuildkiteCI
This commit is contained in:
Florian Klink 2024-08-16 02:24:12 +03:00 committed by clbot
parent 49b173786c
commit 8ea7d2b60e
27 changed files with 555 additions and 461 deletions

View file

@ -29,27 +29,27 @@ impl From<CAHash> for nar_info::Ca {
pub fn log_node(name: &[u8], node: &Node, path: &Path) {
match node {
Node::Directory(directory_node) => {
Node::Directory { digest, .. } => {
debug!(
path = ?path,
name = %name.as_bstr(),
digest = %directory_node.digest(),
digest = %digest,
"import successful",
)
}
Node::File(file_node) => {
Node::File { digest, .. } => {
debug!(
path = ?path,
name = %name.as_bstr(),
digest = %file_node.digest(),
digest = %digest,
"import successful"
)
}
Node::Symlink(symlink_node) => {
Node::Symlink { target } => {
debug!(
path = ?path,
name = %name.as_bstr(),
target = ?symlink_node.target(),
target = ?target,
"import successful"
)
}