pub struct DataId(/* private fields */);Expand description
The id of an input or output port — a manifest outputs: entry, or
the port half of an inputs: entry.
§Examples
use astrs_wire::DataId;
let id: DataId = "detections".parse()?;
assert_eq!(id.to_string(), "detections");Implementations§
Source§impl DataId
impl DataId
Sourcepub fn new(value: impl Into<String>) -> Result<DataId, IdError>
pub fn new(value: impl Into<String>) -> Result<DataId, IdError>
Validates value and wraps it as a data id.
§Errors
IdError if the value is empty, over
MAX_NAME_LEN bytes, or outside [A-Za-z0-9_.-].
§Examples
use astrs_wire::DataId;
assert!(DataId::new("valid-01").is_ok());
assert!(DataId::new("in valid").is_err());Sourcepub fn sanitized(value: &str) -> DataId
pub fn sanitized(value: &str) -> DataId
Wraps value as a data 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::DataId;
assert_eq!(DataId::sanitized("camera.image").as_str(), "camera.image");
assert_eq!(DataId::sanitized("in valid").as_str(), "in_valid");
assert_eq!(DataId::sanitized("").as_str(), "_");Sourcepub fn into_string(self) -> String
pub fn into_string(self) -> String
Consumes the identifier and returns the inner String.