ValidateErrorStore

Struct ValidateErrorStore 

Source
pub struct ValidateErrorStore(pub Arc<[(String, Box<dyn LocaleMessage>)]>);
Expand description

ValidateErrorStore is a structure used to store validation errors, where each error consists of a String key and an associated Box<dyn LocaleMessage> value. The key represents an identifier (e.g., field name or error code), while the LocaleMessage represents a localizable message for the associated validation error.

This structure is designed to be Default and makes use of an Arc<[]> to share ownership of the data, enabling efficient cloning and concurrent usage in multithreaded contexts.

§Fields

  • 0: A reference-counted array (Arc<[]>) of tuples containing:
    • String: The identifier for the validation error.
    • Box<dyn LocaleMessage>: A boxed trait object to represent a localizable message dynamically.

§Traits

The struct derives the Default trait so it can be initialized with an empty error store.

Tuple Fields§

§0: Arc<[(String, Box<dyn LocaleMessage>)]>

Implementations§

Source§

impl ValidateErrorStore

Source

pub fn as_original_message(&self) -> Arc<[String]>

Converts the internal vector representation of the original message into an Arc<[String]>, a thread-safe, shared, and reference-counted slice of strings.

§Returns

An Arc<[String]> containing the original message as a shared reference. The Arc allows multiple threads to safely share ownership of the message data without requiring additional cloning or copying of the underlying strings.

§Usage

This method can be used when you need a thread-safe, immutable reference to the original message structure, allowing for efficient sharing of data across threads.

§Implementation

Internally, the method calls as_original_message_vec() to retrieve the original message as a Vec<String> and then converts it to an Arc<[String]>.

Source

pub fn as_original_message_vec(&self) -> Vec<String>

Converts the current collection into a Vec<String> containing the original messages.

§Description

This method iterates over the elements of the internal collection, extracts the original message (assumed to be stored as the first element of each component, e.0), clones it, and collects all the cloned messages into a new Vec<String>.

§Returns

A Vec<String> containing the cloned original messages from each element in the collection.

§Notes
  • The internal structure self.0 must be iterable, and each element must have a 0 field containing a String-like value.
  • The result is a completely new vector and does not modify the internal state of the current collection.
§Complexity

This method has a time complexity of O(n), where n is the number of elements in the internal collection self.0.

Source

pub fn as_validate_error_collector(&self) -> ValidateErrorCollector

Converts the current instance into a ValidateErrorCollector.

This method takes the current object, clones it, and converts it into a ValidateErrorCollector instance. It is useful when you want to transform the current object to a ValidateErrorCollector for further processing or validation error handling.

§Returns

A ValidateErrorCollector created by cloning and converting the current object.

Trait Implementations§

Source§

impl Clone for ValidateErrorStore

Source§

fn clone(&self) -> Self

Returns a duplicate 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 ValidateErrorStore

Source§

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

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

impl Default for ValidateErrorStore

Source§

fn default() -> ValidateErrorStore

Returns the “default value” for a type. Read more
Source§

impl Into<ValidateErrorCollector> for ValidateErrorStore

Source§

fn into(self) -> ValidateErrorCollector

Converts this type into the (usually inferred) input type.
Source§

impl Into<ValidateErrorStore> for &DateError

Available on crate feature chrono only.
Source§

fn into(self) -> ValidateErrorStore

Converts this type into the (usually inferred) input type.
Source§

impl Into<ValidateErrorStore> for &DateTimeError

Available on crate feature chrono only.
Source§

fn into(self) -> ValidateErrorStore

Converts this type into the (usually inferred) input type.
Source§

impl Into<ValidateErrorStore> for &DateTimeError

Available on crate feature humantime only.
Source§

fn into(self) -> ValidateErrorStore

Converts this type into the (usually inferred) input type.
Source§

impl Into<ValidateErrorStore> for &DescriptionError

Source§

fn into(self) -> ValidateErrorStore

Converts this type into the (usually inferred) input type.
Source§

impl Into<ValidateErrorStore> for &EmailError

Available on crate feature email only.
Source§

fn into(self) -> ValidateErrorStore

Converts this type into the (usually inferred) input type.
Source§

impl Into<ValidateErrorStore> for &FloatError

Source§

fn into(self) -> ValidateErrorStore

Converts this type into the (usually inferred) input type.
Source§

impl Into<ValidateErrorStore> for &IntegerError

Source§

fn into(self) -> ValidateErrorStore

Converts this type into the (usually inferred) input type.
Source§

impl Into<ValidateErrorStore> for &NaiveDateTimeError

Available on crate feature chrono only.
Source§

fn into(self) -> ValidateErrorStore

Converts this type into the (usually inferred) input type.
Source§

impl Into<ValidateErrorStore> for &NameError

Source§

fn into(self) -> ValidateErrorStore

Converts this type into the (usually inferred) input type.
Source§

impl Into<ValidateErrorStore> for &PasswordError

Source§

fn into(self) -> ValidateErrorStore

Converts this type into the (usually inferred) input type.
Source§

impl Into<ValidateErrorStore> for &TimeError

Available on crate feature chrono only.
Source§

fn into(self) -> ValidateErrorStore

Converts this type into the (usually inferred) input type.
Source§

impl Into<ValidateErrorStore> for &UnsignedError

Source§

fn into(self) -> ValidateErrorStore

Converts this type into the (usually inferred) input type.
Source§

impl Into<ValidateErrorStore> for &UrlError

Available on crate feature url only.
Source§

fn into(self) -> ValidateErrorStore

Converts this type into the (usually inferred) input type.
Source§

impl Into<ValidateErrorStore> for &UsernameError

Source§

fn into(self) -> ValidateErrorStore

Converts this type into the (usually inferred) input type.
Source§

impl Into<ValidateErrorStore> for ValidateErrorCollector

Source§

fn into(self) -> ValidateErrorStore

Converts this type into the (usually inferred) input type.
Source§

impl PartialEq for ValidateErrorStore

Source§

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

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

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

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.

Auto Trait Implementations§

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> ToOwned for T
where T: Clone,

Source§

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, U> TryFrom<U> for T
where U: Into<T>,

Source§

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>,

Source§

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.
Source§

impl<T> ErasedDestructor for T
where T: 'static,