Conversation
Introduce error types for recoverable composition failures. CompositionError is #[non_exhaustive] to allow future variants (e.g. arc cycles). DependencyKind distinguishes sublayer, reference, and payload arcs.
Replace flat collect_asset_paths (Vec<String>) with collect_dependencies returning typed Dependency structs with DependencyKind and prim_path. Add collect_layers_with_handler for callers that need custom error handling. The existing collect_layers passes a default handler that converts errors to hard failures, preserving current behavior.
Stage::open now takes only a path and uses DefaultResolver with strict
error handling. For custom resolvers or error tolerance, use the builder:
Stage::builder()
.resolver(custom_resolver)
.on_error(|e| { log(e); Ok(()) })
.open(path)?
StageBuilder uses type parameters for both the resolver and error handler,
avoiding heap allocation in all paths.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Ref: #45
This PR refactors how layers are collected when opening a stage.
Previously, any unresolvable transitive dependency (missing reference, payload, or sublayer) was a hard error that immediately aborted
Stage::open. This matches strict correctness but doesn't match how C++ USD works —UsdStage::Opensucceeds even when some referenced files are missing, reporting errors throughGetCompositionErrors().In this implementation, callers can provide an error callback via
StageBuilder::on_errorthat is invoked for each composition error encountered. The callback receives aCompositionErrorwith full context (asset path, referencing layer, dependency kind, prim path) and returnsResult<()>— returnOk(())to skip the dependency and continue, orErrto abort. The default behavior (no callback) preserves the current hard-error semantics.