Skip to content

Commit

Permalink
Improve the docstring of EntityPath
Browse files Browse the repository at this point in the history
  • Loading branch information
emilk committed Dec 12, 2023
1 parent 2389aed commit 7201623
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 11 deletions.
19 changes: 9 additions & 10 deletions crates/re_log_types/src/path/entity_path.rs
Original file line number Diff line number Diff line change
Expand Up @@ -67,22 +67,21 @@ impl std::fmt::Debug for EntityPathHash {

// ----------------------------------------------------------------------------

/// The unique identifier of an entity, e.g. `camera/"ACME Örnöga"/points`
/// The unique identifier of an entity, e.g. `camera/3/points`
///
/// The entity path is a list of [parts][EntityPathPart] separated by slashes.
/// Each part is a non-empty string, that can contain any character.
/// When written as a string, some characters in the parts need to be escaped with a `\`
/// (only character, numbers, `.`, `-`, `_` does not need escaping).
///
/// Each part is either a [_name_][EntityPathPart::Name] of a limited set of characters,
/// or an [`Index`][crate::Index].
/// Names are like idenitifers in code, and must match the regex: `[a-zA-z0-9_-]+`
/// Indices are like array indices or keys in a map or table, and can be any string,
/// uuid, or number.
/// See <https://www.rerun.io/docs/concepts/entity-path> for more on entity paths.
///
/// Reference-counted internally, so this is cheap to clone.
///
/// Implements [`nohash_hasher::IsEnabled`].
/// `EntityPath` is reference-counted internally, so it is cheap to clone.
/// It also has a precomputed hash and implemented [`nohash_hasher::IsEnabled`],
/// so it is very cheap to use in a [`nohash_hasher::IntMap`] and [`nohash_hasher::IntSet`].
///
/// ```
/// # use re_log_types::{EntityPath, EntityPathPart};
/// # use re_log_types::EntityPath;
/// assert_eq!(
/// EntityPath::parse_strict(r#"camera/ACME\ Örnöga/points/42"#).unwrap(),
/// EntityPath::new(vec![
Expand Down
2 changes: 1 addition & 1 deletion crates/re_log_types/src/path/entity_path_impl.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use crate::path::EntityPathPart;

/// `camera / "left" / points / #42`
/// `camera/left/points/42`
///
/// Wrapped by [`crate::EntityPath`] together with a hash.
#[derive(Clone, PartialEq, Eq, Hash, PartialOrd, Ord)]
Expand Down
2 changes: 2 additions & 0 deletions crates/re_log_types/src/path/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ pub use parse_path::PathParseError;

/// The different parts that make up an [`EntityPath`].
///
/// A non-empty string.
///
/// In the file system analogy, this is the name of a folder.
#[derive(Clone, Debug, Hash, PartialEq, Eq)]
#[cfg_attr(feature = "serde", derive(serde::Deserialize, serde::Serialize))]
Expand Down

0 comments on commit 7201623

Please sign in to comment.