Struct Name

Source
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

Source

pub const CORE: &'static Self

The string “core”.

Source

pub const OCEAN: &'static Self

The string “ocean”.

Source

pub const SELF: &'static Self

The string “self”.

Source

pub const RESERVED_SCOPES: &'static [&'static Self]

Namespaces reserved to only be used only by Ocean.

Source

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.

Source

pub unsafe fn new_unchecked<N>(name: &N) -> &Self
where N: ?Sized + AsRef<[u8]>,

Creates a new instance without parsing name.

Source

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.

Source

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.

Source

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.

Source

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

Converts self to the underlying UTF-8 string slice.

Source

pub fn into_boxed(&self) -> Box<Self>

Moves copied contents of self to the heap.

Source

pub fn is_reserved_scope(&self) -> bool

Returns whether Ocean reserves the right to use this name as a scope.

Trait Implementations§

Source§

impl AsRef<[u8]> for Name

Source§

fn as_ref(&self) -> &[u8]

Converts this type into a shared reference of the (usually inferred) input type.
Source§

impl AsRef<str> for Name

Source§

fn as_ref(&self) -> &str

Converts this type into a shared reference of the (usually inferred) input type.
Source§

impl Clone for Box<Name>

Source§

fn clone(&self) -> Self

Returns a copy of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Name

Source§

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

Formats the value using the given formatter. Read more
Source§

impl<'de: 'a, 'a> Deserialize<'de> for &'a Name

Source§

fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
where D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl<'de> Deserialize<'de> for Box<Name>

Source§

fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
where D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl Display for Name

Source§

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

Formats the value using the given formatter. Read more
Source§

impl From<&Name> for Box<Name>

Source§

fn from(name: &Name) -> Self

Converts to this type from the input type.
Source§

impl Hash for Name

Source§

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

Feeds this value into the given Hasher. Read more
Source§

impl Ord for Name

Source§

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

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

impl PartialEq<[u8]> for Name

Source§

fn eq(&self, b: &[u8]) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

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

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl PartialEq<Name> for [u8]

Source§

fn eq(&self, n: &Name) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

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

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl PartialEq<Name> for str

Source§

fn eq(&self, n: &Name) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

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

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl PartialEq<str> for Name

Source§

fn eq(&self, s: &str) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

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

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl PartialEq for Name

Source§

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

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

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

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl PartialOrd for Name

Source§

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

This method returns an ordering between self and other values if one exists. Read more
1.0.0 · 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 · 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 · 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 · 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
Source§

impl Serialize for Name

Source§

fn serialize<S: Serializer>(&self, s: S) -> Result<S::Ok, S::Error>

Serialize this value into the given Serde serializer. Read more
Source§

impl<'a> TryFrom<&'a [u8]> for &'a Name

Source§

type Error = ValidateError

The type returned in the event of a conversion error.
Source§

fn try_from(bytes: &'a [u8]) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl<'a> TryFrom<&'a CStr> for &'a Name

Source§

type Error = ValidateError

The type returned in the event of a conversion error.
Source§

fn try_from(s: &'a CStr) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl<'a> TryFrom<&'a OsStr> for &'a Name

Source§

type Error = ValidateError

The type returned in the event of a conversion error.
Source§

fn try_from(s: &'a OsStr) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl<'a> TryFrom<&'a str> for &'a Name

Source§

type Error = ValidateError

The type returned in the event of a conversion error.
Source§

fn try_from(s: &'a str) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl TryFrom<&str> for Box<Name>

Source§

type Error = ValidateError

The type returned in the event of a conversion error.
Source§

fn try_from(s: &str) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl Eq for Name

Source§

impl StructuralPartialEq for Name

Auto Trait Implementations§

§

impl Freeze for Name

§

impl RefUnwindSafe for Name

§

impl Send for Name

§

impl !Sized for Name

§

impl Sync for Name

§

impl Unpin for Name

§

impl UnwindSafe for Name

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