Struct InterfaceName
#[repr(transparent)]pub struct InterfaceName(str);Expand description
Name of an interface in the form of a reversed domain name, such as
org.example.ftp.
Tuple Fields§
§0: strImplementations§
§impl InterfaceName
impl InterfaceName
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 interface names.
This is meant for const contexts, where an invalid name fails the
build:
use varlet_idl::InterfaceName;
const NAME: &InterfaceName = InterfaceName::from_static("org.example.ftp");
assert_eq!(NAME.as_str(), "org.example.ftp");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 interface names.
The name consists of at least two segments separated by .. Segments
contain letters, digits and -, but don’t start or end with -. The
first segment starts with a letter.
§Errors
Returns the position of the first byte that breaks the rules.
const fn check(rest: &[u8]) -> Result<(), InvalidName>
const fn check(rest: &[u8]) -> Result<(), InvalidName>
Checks the bytes of a name against the rules.