Skip to main content

openusd_rs/sdf/
abstract_data.rs

1use crate::{sdf, tf, vt};
2
3/// Interface for scene description data storage.
4pub trait AbstractData {
5	/// Return the type of the spec at `path`.
6	fn spec_type(&self, path: &sdf::Path) -> Option<sdf::SpecType>;
7
8	/// Return the value for the given `path` and `field`.
9	fn get(&self, path: &sdf::Path, field: &tf::Token) -> Option<vt::Value>;
10
11	/// Return the names of all the fields that are set at `path`.
12	fn list(&self, path: &sdf::Path) -> Vec<&tf::Token>;
13
14	/// Visit every spec in this AbstractData object in arbitrary order.
15	fn visit_specs(&self) -> Vec<&sdf::Path>;
16}
17
18pub fn debug_dump(data: &dyn sdf::AbstractData) {
19	println!("AbstractData dump");
20	println!("Spec count: {}\n", data.visit_specs().len());
21
22	for path in data.visit_specs() {
23		let spec_type = data.spec_type(path).unwrap();
24		println!("[{:?}] {}", spec_type, path);
25
26		for field in data.list(path) {
27			if let Some(value) = data.get(path, field) {
28				println!("    {} = {:?}", field, value);
29			}
30		}
31	}
32}