pub struct EnvironmentName(/* private fields */);Expand description
Validated environment name following restricted format rules
Environment names are used to isolate different deployment environments and must follow specific naming conventions for consistency and compatibility.
§Examples
use torrust_tracker_deployer_types::EnvironmentName;
// Valid environment names
let dev = EnvironmentName::new("dev".to_string())?;
let staging = EnvironmentName::new("staging".to_string())?;
let e2e_config = EnvironmentName::new("e2e-config".to_string())?;
Implementations§
Source§impl EnvironmentName
impl EnvironmentName
Sourcepub fn new<S>(name: S) -> Result<EnvironmentName, EnvironmentNameError>
pub fn new<S>(name: S) -> Result<EnvironmentName, EnvironmentNameError>
Creates a new EnvironmentName from a string with validation.
§Arguments
name- Environment name that can be converted to a string
§Validation Rules
- Non-empty: Must contain at least one character
- Lowercase only: Only lowercase ASCII letters allowed
- Numbers allowed: ASCII digits 0-9 are permitted
- Dashes only: Only dashes (-) allowed as separators (no underscores or slashes)
- No leading/trailing separators: Cannot start or end with dashes
- No consecutive separators: Cannot contain multiple consecutive dashes
- No leading numbers: Cannot start with a digit
§Examples
// Valid names - accepts various string types
assert!(EnvironmentName::new("dev").is_ok());
assert!(EnvironmentName::new("e2e-config".to_string()).is_ok());
assert!(EnvironmentName::new(String::from("staging123")).is_ok());
// Invalid names
assert!(EnvironmentName::new("").is_err()); // Empty
assert!(EnvironmentName::new("Dev").is_err()); // Uppercase
assert!(EnvironmentName::new("dev_test").is_err()); // Underscore
assert!(EnvironmentName::new("123prod").is_err()); // Starts with number§Errors
Returns EnvironmentNameError with specific validation failure details
and actionable guidance for fixing the name format.
Trait Implementations§
Source§impl AsRef<str> for EnvironmentName
impl AsRef<str> for EnvironmentName
Source§impl Clone for EnvironmentName
impl Clone for EnvironmentName
Source§fn clone(&self) -> EnvironmentName
fn clone(&self) -> EnvironmentName
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 EnvironmentName
impl Debug for EnvironmentName
Source§impl<'de> Deserialize<'de> for EnvironmentName
impl<'de> Deserialize<'de> for EnvironmentName
Source§fn deserialize<__D>(
__deserializer: __D,
) -> Result<EnvironmentName, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(
__deserializer: __D,
) -> Result<EnvironmentName, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Source§impl Display for EnvironmentName
impl Display for EnvironmentName
impl Eq for EnvironmentName
Source§impl Hash for EnvironmentName
impl Hash for EnvironmentName
Source§impl PartialEq for EnvironmentName
impl PartialEq for EnvironmentName
Source§impl Serialize for EnvironmentName
impl Serialize for EnvironmentName
Source§fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
Serialize this value into the given Serde serializer. Read more
impl StructuralPartialEq for EnvironmentName
Auto Trait Implementations§
impl Freeze for EnvironmentName
impl RefUnwindSafe for EnvironmentName
impl Send for EnvironmentName
impl Sync for EnvironmentName
impl Unpin for EnvironmentName
impl UnsafeUnpin for EnvironmentName
impl UnwindSafe for EnvironmentName
Blanket Implementations§
Source§impl<T> AsUncased for T
impl<T> AsUncased for T
Source§fn as_uncased(&self) -> &UncasedStr
fn as_uncased(&self) -> &UncasedStr
Convert
self to an UncasedStr.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,
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§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.Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
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> ⓘ
Converts
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> ⓘ
Converts
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> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
Wrap the input message
T in a tonic::RequestSource§impl<T> IntoResult<T> for T
impl<T> IntoResult<T> for T
type Err = !
fn into_result(self) -> Result<T, <T as IntoResult<T>>::Err>
Source§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt for Twhere
T: ?Sized,
Source§impl<T> ToStringFallible for Twhere
T: Display,
impl<T> ToStringFallible for Twhere
T: Display,
Source§fn try_to_string(&self) -> Result<String, TryReserveError>
fn try_to_string(&self) -> Result<String, TryReserveError>
ToString::to_string, but without panic on OOM.