pub struct NodeId(/* private fields */);Expand description
The id of a node in a dataflow — the id: field of a manifest node
(blueprint §8.3).
Module expansion produces dotted composites (parent.child, §8.5),
which is why . is part of the grammar.
§Examples
use astrs_wire::NodeId;
let id: NodeId = "perception.detector".parse()?;
assert_eq!(id.as_str(), "perception.detector");Implementations§
Source§impl NodeId
impl NodeId
Sourcepub fn new(value: impl Into<String>) -> Result<NodeId, IdError>
pub fn new(value: impl Into<String>) -> Result<NodeId, IdError>
Validates value and wraps it as a node id.
§Errors
IdError if the value is empty, over
MAX_NAME_LEN bytes, or outside [A-Za-z0-9_.-].
§Examples
use astrs_wire::NodeId;
assert!(NodeId::new("valid-01").is_ok());
assert!(NodeId::new("in valid").is_err());Sourcepub fn sanitized(value: &str) -> NodeId
pub fn sanitized(value: &str) -> NodeId
Wraps value as a node id, repairing it if it does not fit the grammar.
A total constructor, for callers that must produce an
identifier and have no error path to take: a reserved literal
this crate itself defines, a metrics label derived from
operator-supplied text, a fallback in a Display impl.
Characters outside [A-Za-z0-9_.-] become _, the result is
truncated to MAX_NAME_LEN bytes on a character boundary,
and an empty result becomes "_" — so the returned value
always satisfies the same invariant Self::new enforces.
Prefer Self::new wherever a malformed name is a real error
worth reporting; silent repair is the right answer only when
there is nobody to report it to.
§Examples
use astrs_wire::NodeId;
assert_eq!(NodeId::sanitized("camera.image").as_str(), "camera.image");
assert_eq!(NodeId::sanitized("in valid").as_str(), "in_valid");
assert_eq!(NodeId::sanitized("").as_str(), "_");Sourcepub fn into_string(self) -> String
pub fn into_string(self) -> String
Consumes the identifier and returns the inner String.