Skip to main content

InterfaceName

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: str

Implementations§

§

impl InterfaceName

pub const fn as_str(&self) -> &str

Returns the name as a string.

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>

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>

Checks the bytes of a name against the rules.

const fn cast(name: &str) -> &Self

Trait Implementations§

§

impl Debug for InterfaceName

§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
§

impl Display for InterfaceName

§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
§

impl Eq for InterfaceName

§

impl Hash for InterfaceName

§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
§

impl Ord for InterfaceName

§

fn cmp(&self, other: &InterfaceName) -> Ordering

This method returns an Ordering between self and other. Read more
§

impl PartialEq for InterfaceName

§

fn eq(&self, other: &InterfaceName) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
§

impl PartialOrd for InterfaceName

§

fn partial_cmp(&self, other: &InterfaceName) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 (const: unstable) · Source§

fn lt(&self, other: &Rhs) -> bool

Tests less than (for self and other) and is used by the < operator. Read more
1.0.0 (const: unstable) · Source§

fn le(&self, other: &Rhs) -> bool

Tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 (const: unstable) · Source§

fn gt(&self, other: &Rhs) -> bool

Tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 (const: unstable) · Source§

fn ge(&self, other: &Rhs) -> bool

Tests greater than or equal to (for self and other) and is used by the >= operator. Read more
§

impl StructuralPartialEq for InterfaceName

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more