From 0244ae6eaffe1dd938748aaf1cfdf5fdab0c0a57 Mon Sep 17 00:00:00 2001 From: Florian Klink Date: Sat, 20 Jul 2024 16:34:32 +0200 Subject: feat(tvix/castore/protos): return root node after validation This allows avoiding a `.node.unwrap()`` after validation. Change-Id: Ieef1ffebab16cdca94c979ca6831a7ab4f6007da Reviewed-on: https://cl.tvl.fyi/c/depot/+/11989 Reviewed-by: Brian Olsen Tested-by: BuildkiteCI --- tvix/castore/src/proto/mod.rs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'tvix') diff --git a/tvix/castore/src/proto/mod.rs b/tvix/castore/src/proto/mod.rs index 5374e3ae5a80..a0cec896f753 100644 --- a/tvix/castore/src/proto/mod.rs +++ b/tvix/castore/src/proto/mod.rs @@ -116,9 +116,11 @@ impl NamedNode for node::Node { impl Node { /// Ensures the node has a valid enum kind (is Some), and passes its // per-enum validation. - pub fn validate(&self) -> Result<(), ValidateNodeError> { + // The inner root node is returned for easier consumption. + pub fn validate(&self) -> Result<&node::Node, ValidateNodeError> { if let Some(node) = self.node.as_ref() { - node.validate() + node.validate()?; + Ok(node) } else { Err(ValidateNodeError::NoNodeSet) } -- cgit 1.4.1