Struct Name
#[repr(transparent)]pub struct Name(str);Expand description
Name of a type, method or error, such as GetInfo.
It starts with an uppercase letter and continues with letters and digits.
Tuple Fields§
§0: strImplementations§
§impl Name
impl Name
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 type, method and error names.
This is meant for const contexts, where an invalid name fails the
build:
use varlet_idl::Name;
const NAME: &Name = Name::from_static("GetInfo");
assert_eq!(NAME.as_str(), "GetInfo");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 type, method and error 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.