pub struct SafeName(/* private fields */);Expand description
A name that is safe everywhere QCode puts it: as a file name in the store, as part of an image name, and as a container or volume name.
It holds lowercase ASCII letters, digits and single hyphens, and begins and ends with a
letter or digit. Folding is written out character by character rather than left to
str::to_lowercase, so that the same text gives the same name on every machine: in Turkish
I and İ do not fold the way the rest of the world folds them, and a name is a file name.
Implementations§
Source§impl SafeName
impl SafeName
Sourcepub const MAX_LENGTH: usize = 64
pub const MAX_LENGTH: usize = 64
The longest a name may be, in characters. Container engines take far longer names; the limit keeps a name readable in a list and leaves room for the prefixes QCode adds.
Sourcepub fn from_display(text: &str) -> Option<Self>
pub fn from_display(text: &str) -> Option<Self>
Makes a name out of text a person typed, such as a workspace title. Letters fold to ASCII,
everything else becomes a single hyphen, and the result is cut to Self::MAX_LENGTH.
Text without a single usable character has no name.
Sourcepub fn parse(text: &str) -> Option<Self>
pub fn parse(text: &str) -> Option<Self>
Reads a name that is already safe, such as one from a definition file. Text that is not
exactly what Self::from_display would have produced is refused rather than repaired,
so that a file and the name in it can never disagree.
Trait Implementations§
impl Eq for SafeName
Source§impl Ord for SafeName
impl Ord for SafeName
1.21.0 (const: unstable) · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
1.21.0 (const: unstable) · Source§fn min(self, other: Self) -> Selfwhere
Self: Sized,
fn min(self, other: Self) -> Selfwhere
Self: Sized,
Source§impl PartialOrd for SafeName
impl PartialOrd for SafeName
impl StructuralPartialEq for SafeName
Auto Trait Implementations§
impl Freeze for SafeName
impl RefUnwindSafe for SafeName
impl Send for SafeName
impl Sync for SafeName
impl Unpin for SafeName
impl UnsafeUnpin for SafeName
impl UnwindSafe for SafeName
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Comparable<K> for Q
impl<Q, K> Comparable<K> for Q
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.Source§impl<T> DowncastSync for T
impl<T> DowncastSync for T
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> ToCompactString for Twhere
T: Display,
impl<T> ToCompactString for Twhere
T: Display,
Source§fn try_to_compact_string(&self) -> Result<CompactString, ToCompactStringError>
fn try_to_compact_string(&self) -> Result<CompactString, ToCompactStringError>
ToCompactString::to_compact_string() Read moreSource§fn to_compact_string(&self) -> CompactString
fn to_compact_string(&self) -> CompactString
CompactString. Read more