Skip to content

Commit de6882a

Browse files
committed
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 <me@griff.name> Tested-by: BuildkiteCI
1 parent da2a6e0 commit de6882a

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

castore/src/proto/mod.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -116,9 +116,11 @@ impl NamedNode for node::Node {
116116
impl Node {
117117
/// Ensures the node has a valid enum kind (is Some), and passes its
118118
// per-enum validation.
119-
pub fn validate(&self) -> Result<(), ValidateNodeError> {
119+
// The inner root node is returned for easier consumption.
120+
pub fn validate(&self) -> Result<&node::Node, ValidateNodeError> {
120121
if let Some(node) = self.node.as_ref() {
121-
node.validate()
122+
node.validate()?;
123+
Ok(node)
122124
} else {
123125
Err(ValidateNodeError::NoNodeSet)
124126
}

0 commit comments

Comments
 (0)