pub struct GffLabel { /* private fields */ }Expand description
Canonicalized GFF field label.
GFF labels are identifiers with a maximum length of 16 characters. This type stores
the exact casing of the label as an inline fixed-size buffer, making it Copy and
zero-allocation.
Valid characters are restricted to ASCII alphanumerics, underscores, and spaces ([A-Za-z0-9_ ]).
Implementations§
Source§impl GffLabel
impl GffLabel
Sourcepub fn new(value: impl AsRef<str>) -> Result<Self, GffLabelError>
pub fn new(value: impl AsRef<str>) -> Result<Self, GffLabelError>
Creates and validates a new GFF label.
Accepted characters are ASCII alphanumerics, underscores, and spaces.
Sourcepub const fn from_static(value: &'static str) -> Self
pub const fn from_static(value: &'static str) -> Self
Constructs a GffLabel from a string literal at compile time.
Use this for hardcoded labels in source code. Invalid input becomes
a compile error when the call appears in a const context, and
panics immediately at the call site otherwise – validation cannot
be deferred into a runtime data path.
For runtime input (binary parsing, JSON, user data), use
GffLabel::new which returns a Result.
const TAG: GffLabel = GffLabel::from_static("Tag");
assert_eq!(TAG.as_str(), "Tag");Invalid literals are rejected at compile time when used in a
const context:
const BAD: GffLabel = GffLabel::from_static("Tag!");