pub struct PluginName(/* private fields */);Expand description
A validated plugin name.
A PluginName is guaranteed to satisfy the plugin naming rules:
[a-z][a-z0-9-]*, at most 64 characters, no path separators or dots.
Construct via TryFrom<String> or TryFrom<&str>; both delegate to the
same validate_plugin_name predicate used throughout the plugin manager.
§Examples
use zeph_plugins::PluginName;
let name: PluginName = "my-plugin".try_into().unwrap();
assert_eq!(name.as_str(), "my-plugin");
assert_eq!(name.to_string(), "my-plugin");Implementations§
Trait Implementations§
Source§impl AsRef<str> for PluginName
impl AsRef<str> for PluginName
Source§impl Clone for PluginName
impl Clone for PluginName
Source§fn clone(&self) -> PluginName
fn clone(&self) -> PluginName
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for PluginName
impl Debug for PluginName
Source§impl<'de> Deserialize<'de> for PluginName
impl<'de> Deserialize<'de> for PluginName
Source§fn deserialize<D: Deserializer<'de>>(d: D) -> Result<Self, D::Error>
fn deserialize<D: Deserializer<'de>>(d: D) -> Result<Self, D::Error>
Deserialize this value from the given Serde deserializer. Read more
Source§impl Display for PluginName
impl Display for PluginName
impl Eq for PluginName
Source§impl Hash for PluginName
impl Hash for PluginName
Source§impl Ord for PluginName
impl Ord for PluginName
Source§fn cmp(&self, other: &PluginName) -> Ordering
fn cmp(&self, other: &PluginName) -> Ordering
1.21.0 (const: unstable) · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
Compares and returns the maximum of two values. Read more
Source§impl PartialEq for PluginName
impl PartialEq for PluginName
Source§fn eq(&self, other: &PluginName) -> bool
fn eq(&self, other: &PluginName) -> bool
Tests for
self and other values to be equal, and is used by ==.Source§impl PartialEq<&str> for PluginName
impl PartialEq<&str> for PluginName
Source§impl PartialEq<String> for PluginName
impl PartialEq<String> for PluginName
Source§impl PartialEq<str> for PluginName
impl PartialEq<str> for PluginName
Source§impl PartialOrd for PluginName
impl PartialOrd for PluginName
Source§impl Serialize for PluginName
impl Serialize for PluginName
impl StructuralPartialEq for PluginName
Source§impl TryFrom<&str> for PluginName
impl TryFrom<&str> for PluginName
Source§fn try_from(value: &str) -> Result<Self, Self::Error>
fn try_from(value: &str) -> Result<Self, Self::Error>
Validate and wrap a plugin name from a string slice.
§Errors
Returns PluginError::InvalidName when the string does not satisfy the
naming rules: [a-z][a-z0-9-]*, at most 64 characters, no path separators
or dots.
§Examples
use zeph_plugins::PluginName;
let ok: PluginName = PluginName::try_from("another-plugin").unwrap();
assert_eq!(ok.as_str(), "another-plugin");
let err = PluginName::try_from("BAD");
assert!(err.is_err());Source§type Error = PluginError
type Error = PluginError
The type returned in the event of a conversion error.
Source§impl TryFrom<String> for PluginName
impl TryFrom<String> for PluginName
Source§fn try_from(value: String) -> Result<Self, Self::Error>
fn try_from(value: String) -> Result<Self, Self::Error>
Validate and wrap a plugin name.
§Errors
Returns PluginError::InvalidName when the string does not satisfy the
naming rules: [a-z][a-z0-9-]*, at most 64 characters, no path separators
or dots.
§Examples
use zeph_plugins::PluginName;
let ok: PluginName = PluginName::try_from("valid-name".to_owned()).unwrap();
assert_eq!(ok.as_str(), "valid-name");
// Uppercase letters are rejected.
let err = PluginName::try_from("Invalid_Name".to_owned());
assert!(err.is_err());
// Empty string is rejected.
let err = PluginName::try_from(String::new());
assert!(err.is_err());
// Names longer than 64 characters are rejected.
let err = PluginName::try_from("a".repeat(65));
assert!(err.is_err());Source§type Error = PluginError
type Error = PluginError
The type returned in the event of a conversion error.
Auto Trait Implementations§
impl Freeze for PluginName
impl RefUnwindSafe for PluginName
impl Send for PluginName
impl Sync for PluginName
impl Unpin for PluginName
impl UnsafeUnpin for PluginName
impl UnwindSafe for PluginName
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
Mutably borrows from an owned value. Read more
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
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
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
Compare self to
key and return true if they are equal.