1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77
//! Every logged entity in Rerun is logged to an [`EntityPath`].
//!
//! The path is made up out of several [`EntityPathPart`]s,
//! which are just non-empty strings.
mod component_path;
mod data_path;
mod entity_path;
mod entity_path_filter;
mod entity_path_part;
mod natural_ordering;
mod parse_path;
pub use component_path::ComponentPath;
pub use data_path::DataPath;
pub use entity_path::{EntityPath, EntityPathHash};
pub use entity_path_filter::{EntityPathFilter, EntityPathRule, EntityPathSubs, RuleEffect};
pub use entity_path_part::EntityPathPart;
pub use parse_path::PathParseError;
// ----------------------------------------------------------------------------
/// Reexports for use by macros to avoid depending on the caller's namespacing.
#[doc(hidden)]
pub mod __private {
pub use ::std::{string, vec};
}
/// Build a `Vec<EntityPathPart>`:
/// ```
/// # #![no_std] // test that the macro does not depend on the std *prelude*
/// # extern crate std;
/// # fn main() {
/// # use std::vec::Vec;
/// # use re_log_types::*;
/// let parts: Vec<EntityPathPart> = entity_path_vec!("foo", 42, "my image!");
/// # }
/// ```
#[macro_export]
macro_rules! entity_path_vec {
() => {
// A vector of no elements that nevertheless has the expected concrete type.
$crate::path::__private::vec::Vec::<$crate::EntityPathPart>::new()
};
($($part: expr),* $(,)?) => {
$crate::path::__private::vec![ $($crate::EntityPathPart::from(
#[allow(clippy::str_to_string, clippy::string_to_string)]
$crate::path::__private::string::ToString::to_string(&$part)
),)+ ]
};
}
/// Build an [`EntityPath`] from parts that are _not_ escaped:
///
/// ```
/// # use re_log_types::*;
/// let path: EntityPath = entity_path!("world", 42, "my image!");
/// assert_eq!(path, EntityPath::parse_strict(r"world/42/my\ image\!").unwrap());
/// ```
#[macro_export]
macro_rules! entity_path {
($($part: expr),* $(,)?) => {
$crate::EntityPath::from($crate::entity_path_vec![ $($part,)* ])
};
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn entity_path_macros_empty() {
// If the type weren't constrained, this would be an ambiguous type error.
assert_eq!(entity_path_vec!(), vec![]);
assert_eq!(entity_path!(), EntityPath::from(vec![]));
}
}