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
This commit is contained in:
parent
c64c028366
commit
0244ae6eaf
1 changed files with 4 additions and 2 deletions
|
@ -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)
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue