Skip to main content

re_log_types/path/
component_path.rs

1use re_types_core::ComponentIdentifier;
2
3use crate::path::EntityPath;
4
5/// A [`EntityPath`] plus a [`ComponentIdentifier`].
6///
7/// Example: `camera/left/points:Points3D:color`
8#[derive(Clone, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)]
9#[cfg_attr(feature = "serde", derive(serde::Deserialize, serde::Serialize))]
10pub struct ComponentPath {
11    /// `camera / "left" / points / #42`
12    pub entity_path: EntityPath,
13
14    /// e.g. `Points3D:color`
15    pub component: ComponentIdentifier,
16}
17
18impl ComponentPath {
19    #[inline]
20    pub fn new(entity_path: EntityPath, component: ComponentIdentifier) -> Self {
21        Self {
22            entity_path,
23            component,
24        }
25    }
26
27    #[inline]
28    pub fn entity_path(&self) -> &EntityPath {
29        &self.entity_path
30    }
31
32    #[inline]
33    pub fn component(&self) -> &ComponentIdentifier {
34        &self.component
35    }
36}
37
38impl std::fmt::Display for ComponentPath {
39    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
40        self.entity_path.fmt(f)?;
41        f.write_str(":")?;
42        self.component.fmt(f)?;
43        Ok(())
44    }
45}