diff options
author | Florian Klink <flokli@flokli.de> | 2024-07-20T14·34+0200 |
---|---|---|
committer | flokli <flokli@flokli.de> | 2024-07-20T16·35+0000 |
commit | 0244ae6eaffe1dd938748aaf1cfdf5fdab0c0a57 (patch) | |
tree | 996b59c2ccbafca5791ded5eef8c98b02c378509 /tvix/castore/src/proto | |
parent | c64c028366cdcd80af373842f4b10290bddac495 (diff) |
feat(tvix/castore/protos): return root node after validation r/8375
This allows avoiding a `.node.unwrap()`` after validation. Change-Id: Ieef1ffebab16cdca94c979ca6831a7ab4f6007da Reviewed-on: https://cl.tvl.fyi/c/depot/+/11989 Reviewed-by: Brian Olsen <me@griff.name> Tested-by: BuildkiteCI
Diffstat (limited to 'tvix/castore/src/proto')
-rw-r--r-- | tvix/castore/src/proto/mod.rs | 6 |
1 files changed, 4 insertions, 2 deletions
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) } |