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
impl ValidateErrorStore
Sourcepub fn as_original_message(&self) -> Arc<[String]>
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]>
.
Sourcepub fn as_original_message_vec(&self) -> Vec<String>
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 a0
field containing aString
-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
.