Struct NonEmptyText
pub struct NonEmptyText(/* private fields */);Expand description
A string type that guarantees non-empty content.
This type wraps a String and ensures it contains at least one non-whitespace character.
The input is automatically trimmed of leading and trailing whitespace during construction.
Implementations§
§impl NonEmptyText
impl NonEmptyText
pub fn new(input: impl AsRef<str>) -> Result<NonEmptyText, TextError>
pub fn new(input: impl AsRef<str>) -> Result<NonEmptyText, TextError>
Creates a new NonEmptyText from the given input.
The input is trimmed of leading and trailing whitespace. If the trimmed result is empty, an error is returned.
§Arguments
input- Any type that can be converted to a string reference
§Returns
Returns Ok(NonEmptyText) if the trimmed input is non-empty,
or Err(TextError::Empty) if it’s empty or contains only whitespace.
pub fn starts_with(&self, pattern: &str) -> bool
pub fn starts_with(&self, pattern: &str) -> bool
Checks if the text starts with the given pattern.
Trait Implementations§
§impl AsRef<str> for NonEmptyText
impl AsRef<str> for NonEmptyText
§impl Clone for NonEmptyText
impl Clone for NonEmptyText
§fn clone(&self) -> NonEmptyText
fn clone(&self) -> NonEmptyText
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read more§impl Debug for NonEmptyText
impl Debug for NonEmptyText
§impl<'de> Deserialize<'de> for NonEmptyText
impl<'de> Deserialize<'de> for NonEmptyText
§fn deserialize<D>(
deserializer: D,
) -> Result<NonEmptyText, <D as Deserializer<'de>>::Error>where
D: Deserializer<'de>,
fn deserialize<D>(
deserializer: D,
) -> Result<NonEmptyText, <D as Deserializer<'de>>::Error>where
D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
§impl Display for NonEmptyText
impl Display for NonEmptyText
§impl Hash for NonEmptyText
impl Hash for NonEmptyText
§impl PartialEq for NonEmptyText
impl PartialEq for NonEmptyText
§impl Serialize for NonEmptyText
impl Serialize for NonEmptyText
§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 Eq for NonEmptyText
impl StructuralPartialEq for NonEmptyText
Auto Trait Implementations§
impl Freeze for NonEmptyText
impl RefUnwindSafe for NonEmptyText
impl Send for NonEmptyText
impl Sync for NonEmptyText
impl Unpin for NonEmptyText
impl UnwindSafe for NonEmptyText
Blanket Implementations§
§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
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<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Checks if this value is equivalent to the given key. Read more
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§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<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.§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§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::Request