Struct FieldName
#[repr(transparent)]pub struct FieldName(str);Expand description
Name of a field or of an enum variant, such as thing_name.
It starts with a letter and continues with letters and digits. One _
may separate them.
Tuple Fields§
§0: strImplementations§
§impl FieldName
impl FieldName
pub const fn from_static(name: &'static str) -> &'static Self
pub const fn from_static(name: &'static str) -> &'static Self
Checks a static name against the rules for field names.
This is meant for const contexts, where an invalid name fails the
build:
use varlet_idl::FieldName;
const NAME: &FieldName = FieldName::from_static("thing_name");
assert_eq!(NAME.as_str(), "thing_name");Use new for names that come from input.
§Panics
Panics if the name breaks the rules.
pub const fn new(name: &str) -> Result<&Self, InvalidName>
pub const fn new(name: &str) -> Result<&Self, InvalidName>
Checks name against the rules for field names.
§Errors
Returns the position of the first byte that breaks the rules.
pub(crate) const fn equals(&self, other: &Self) -> bool
const fn check(rest: &[u8]) -> Result<(), InvalidName>
const fn check(rest: &[u8]) -> Result<(), InvalidName>
Checks the bytes of a name against the rules.