use crate::{
sdf, tf, usd,
vt::{self, ValueType},
};
pub struct Object<'a> {
stage: &'a usd::Stage,
path: sdf::Path,
}
impl<'a> Object<'a> {
pub(crate) fn new(stage: &'a usd::Stage, path: sdf::Path) -> Self {
Object { stage, path }
}
pub fn stage(&self) -> &usd::Stage {
self.stage
}
pub fn path(&self) -> &sdf::Path {
&self.path
}
pub fn metadata<T: ValueType>(&self, key: &tf::Token) -> Option<T> {
self.stage()
.data()
.get(self.path(), key)
.map(|v| v.get::<T>())
.flatten()
}
pub fn documentation(&self) -> String {
self.metadata(&sdf::FIELD_KEYS.documentation)
.unwrap_or_default()
}
pub fn custom_data(&self) -> vt::Dictionary {
self.metadata(&sdf::FIELD_KEYS.custom_data)
.unwrap_or_default()
}
}