1use crate::{
2 sdf, tf, usd,
3 vt::{self, ValueType},
4};
5
6pub struct Object<'a> {
19 stage: &'a usd::Stage,
20 path: sdf::Path,
21}
22
23impl<'a> Object<'a> {
24 pub(crate) fn new(stage: &'a usd::Stage, path: sdf::Path) -> Self {
25 Object { stage, path }
26 }
27
28 pub fn stage(&self) -> &usd::Stage {
29 self.stage
30 }
31
32 pub fn path(&self) -> &sdf::Path {
33 &self.path
34 }
35
36 pub fn metadata<T: ValueType>(&self, key: &tf::Token) -> Option<T> {
37 self.stage()
38 .data()
39 .get(self.path(), key)
40 .map(|v| v.get::<T>())
41 .flatten()
42 }
43
44 pub fn documentation(&self) -> String {
48 self.metadata(&sdf::FIELD_KEYS.documentation)
49 .unwrap_or_default()
50 }
51
52 pub fn custom_data(&self) -> vt::Dictionary {
54 self.metadata(&sdf::FIELD_KEYS.custom_data)
55 .unwrap_or_default()
56 }
57}