Struct secret_tree::Name

source ·
pub struct Name(/* private fields */);
Expand description

Name of a child SecretTree.

Used in SecretTree::child(); see its documentation for more context.

An original str can be extracted from Name using AsRef / Display implementations:

const NAME: Name = Name::new("test_name");
assert_eq!(NAME.as_ref(), "test_name");
assert_eq!(NAME.to_string(), "test_name");

Implementations§

source§

impl Name

source

pub const fn new(name: &str) -> Self

Creates a new Name.

The supplied string must be no more than MAX_NAME_LEN bytes in length and must not contain null chars '\0'.

This is a constant method, which perform all relevant checks during compilation in a constant context:

const NAME: Name = Name::new("some_name");

For example, this won’t compile since the name is too long (17 chars):

const OVERLY_LONG_NAME: Name = Name::new("Overly long name!");

…And this won’t compile because the name contains a \0 char:

const NAME_WITH_ZERO_CHARS: Name = Name::new("12\03");
§Panics

Panics if name is overly long or contains null chars. Use the FromStr implementation for a fallible / non-panicking alternative.

Trait Implementations§

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 Name

source§

fn clone(&self) -> Name

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, formatter: &mut Formatter<'_>) -> Result

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

impl Display for Name

source§

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

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

impl FromStr for Name

§

type Err = NameError

The associated error which can be returned from parsing.
source§

fn from_str(name: &str) -> Result<Self, Self::Err>

Parses a string s to return a value of this type. Read more
source§

impl Hash for Name

source§

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

Feeds this value into the given Hasher. Read more
1.3.0 · source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
source§

impl PartialEq for Name

source§

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

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

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

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl Copy for Name

source§

impl Eq for Name

source§

impl StructuralPartialEq for Name

Auto Trait Implementations§

§

impl RefUnwindSafe for Name

§

impl Send 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> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> Same for T

§

type Output = T

Should always be Self
source§

impl<T> ToOwned for T
where T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

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

source§

default fn to_string(&self) -> String

Converts the given value to a String. Read more
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

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

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V