pub struct Name(/* private fields */);
Expand description
A valid drop name.
Valid names are non-empty, lowercase ASCII alphanumeric, and can have dashes
(-
) anywhere except for the beginning or end.
Implementations§
Source§impl Name
impl Name
Sourcepub const RESERVED_SCOPES: &'static [&'static Self]
pub const RESERVED_SCOPES: &'static [&'static Self]
Namespaces reserved to only be used only by Ocean.
Sourcepub fn new<'a, N>(name: N) -> Result<&'a Self, ValidateError>where
N: TryInto<&'a Self, Error = ValidateError>,
pub fn new<'a, N>(name: N) -> Result<&'a Self, ValidateError>where
N: TryInto<&'a Self, Error = ValidateError>,
Attempts to create a new instance by parsing name
.
Sourcepub unsafe fn new_unchecked<N>(name: &N) -> &Self
pub unsafe fn new_unchecked<N>(name: &N) -> &Self
Creates a new instance without parsing name
.
Sourcepub fn is_valid<N: AsRef<[u8]>>(name: N) -> bool
pub fn is_valid<N: AsRef<[u8]>>(name: N) -> bool
Returns whether name
is valid.
All characters in name
must match the regex [0-9a-z-]
, with the
exception of the first and last character where -
is not allowed.
Sourcepub fn is_valid_ascii(byte: u8) -> bool
pub fn is_valid_ascii(byte: u8) -> bool
Returns whether byte
is valid within a name.
Regex: [0-9a-z-]
.
Note that this returns true
for -
despite it being invalid at the
start and end of a full name.
Sourcepub fn is_valid_char(ch: char) -> bool
pub fn is_valid_char(ch: char) -> bool
Returns whether the unicode scalar is valid within a name.
See is_valid_ascii
for more info.
Sourcepub fn into_boxed(&self) -> Box<Self>
pub fn into_boxed(&self) -> Box<Self>
Moves copied contents of self
to the heap.
Sourcepub fn is_reserved_scope(&self) -> bool
pub fn is_reserved_scope(&self) -> bool
Returns whether Ocean reserves the right to use this name as a scope.