Skip to main content

qubit_value/multi_values/
multi_values_accessors.rs

1use std::collections::HashMap;
2use std::time::Duration;
3
4use bigdecimal::BigDecimal;
5use chrono::{DateTime, NaiveDate, NaiveDateTime, NaiveTime, Utc};
6use num_bigint::BigInt;
7use url::Url;
8
9use qubit_common::lang::DataType;
10
11use crate::value_error::{ValueError, ValueResult};
12
13use super::multi_values::MultiValues;
14use super::multi_values_add_arg::MultiValuesAddArg;
15use super::multi_values_adder::MultiValuesAdder;
16use super::multi_values_constructor::MultiValuesConstructor;
17use super::multi_values_first_getter::MultiValuesFirstGetter;
18use super::multi_values_getter::MultiValuesGetter;
19use super::multi_values_multi_adder::MultiValuesMultiAdder;
20use super::multi_values_set_arg::MultiValuesSetArg;
21use super::multi_values_setter::MultiValuesSetter;
22use super::multi_values_setter_slice::MultiValuesSetterSlice;
23use super::multi_values_single_setter::MultiValuesSingleSetter;
24
25impl MultiValues {
26    /// Generic constructor method
27    ///
28    /// Creates `MultiValues` from `Vec<T>`, avoiding direct use of enum
29    /// variants.
30    ///
31    /// # Type Parameters
32    ///
33    /// * `T` - Element type
34    ///
35    /// # Returns
36    ///
37    /// Returns `MultiValues` wrapping the given value list
38    ///
39    /// # Example
40    ///
41    /// ```rust
42    /// use qubit_value::MultiValues;
43    ///
44    /// // Basic types
45    /// let mv = MultiValues::new(vec![1, 2, 3]);
46    /// assert_eq!(mv.count(), 3);
47    ///
48    /// // Strings
49    /// let mv = MultiValues::new(vec!["a".to_string(), "b".to_string()]);
50    /// assert_eq!(mv.count(), 2);
51    /// ```
52    #[inline]
53    pub fn new<T>(values: Vec<T>) -> Self
54    where
55        Self: MultiValuesConstructor<T>,
56    {
57        <Self as MultiValuesConstructor<T>>::from_vec(values)
58    }
59
60    /// Generic getter method for multiple values
61    ///
62    /// Automatically selects the correct getter method based on the target
63    /// type, performing strict type checking.
64    ///
65    /// # Type Parameters
66    ///
67    /// * `T` - The target element type to retrieve.
68    ///
69    /// # Returns
70    ///
71    /// If types match, returns the list of values; otherwise returns an error.
72    ///
73    /// # Example
74    ///
75    /// ```rust
76    /// use qubit_value::MultiValues;
77    ///
78    /// let multi = MultiValues::Int32(vec![1, 2, 3]);
79    ///
80    /// // Through type inference
81    /// let nums: Vec<i32> = multi.get().unwrap();
82    /// assert_eq!(nums, vec![1, 2, 3]);
83    ///
84    /// // Explicitly specify type parameter
85    /// let nums = multi.get::<i32>().unwrap();
86    /// assert_eq!(nums, vec![1, 2, 3]);
87    /// ```
88    #[inline]
89    pub fn get<T>(&self) -> ValueResult<Vec<T>>
90    where
91        Self: MultiValuesGetter<T>,
92    {
93        <Self as MultiValuesGetter<T>>::get_values(self)
94    }
95
96    /// Generic getter method for the first value
97    ///
98    /// Automatically selects the correct getter method based on the target type,
99    /// performing strict type checking.
100    ///
101    /// # Type Parameters
102    ///
103    /// * `T` - The target element type to retrieve.
104    ///
105    /// # Returns
106    ///
107    /// If types match and a value exists, returns the first value; otherwise
108    /// returns an error.
109    ///
110    /// # Example
111    ///
112    /// ```rust
113    /// use qubit_value::MultiValues;
114    ///
115    /// let multi = MultiValues::Int32(vec![42, 100, 200]);
116    ///
117    /// // Through type inference
118    /// let first: i32 = multi.get_first().unwrap();
119    /// assert_eq!(first, 42);
120    ///
121    /// // Explicitly specify type parameter
122    /// let first = multi.get_first::<i32>().unwrap();
123    /// assert_eq!(first, 42);
124    ///
125    /// // String type
126    /// let multi = MultiValues::String(vec!["hello".to_string(), "world".to_string()]);
127    /// let first: String = multi.get_first().unwrap();
128    /// assert_eq!(first, "hello");
129    /// ```
130    #[inline]
131    pub fn get_first<T>(&self) -> ValueResult<T>
132    where
133        Self: MultiValuesFirstGetter<T>,
134    {
135        <Self as MultiValuesFirstGetter<T>>::get_first_value(self)
136    }
137
138    /// Generic setter method
139    ///
140    /// Automatically selects the optimal setter path based on the input type,
141    /// replacing the entire list.
142    ///
143    /// This operation updates the stored type to the input element type and
144    /// does not validate runtime compatibility with the previous variant.
145    ///
146    /// Supports three input forms, all unified to this method via internal
147    /// dispatch traits:
148    ///
149    /// - `Vec<T>`: Takes `set_values(Vec<T>)` path with zero additional allocation
150    /// - `&[T]`: Takes `set_values_slice(&[T])` path
151    /// - `T`: Takes `set_single_value(T)` path
152    ///
153    /// # Type Parameters
154    ///
155    /// * `S` - Input type, can be `Vec<T>`, `&[T]`, or a single `T`
156    ///
157    /// # Parameters
158    ///
159    /// * `values` - The value collection to set, can be `Vec<T>`, `&[T]`, or a
160    ///   single `T`
161    ///
162    /// # Returns
163    ///
164    /// If setting succeeds, returns `Ok(())`; otherwise returns an error.
165    ///
166    /// # Example
167    ///
168    /// ```rust
169    /// use qubit_common::lang::DataType;
170    /// use qubit_value::MultiValues;
171    ///
172    /// // 1) Vec<T>
173    /// let mut mv = MultiValues::Empty(DataType::Int32);
174    /// mv.set(vec![42, 100, 200]).unwrap();
175    /// assert_eq!(mv.get_int32s().unwrap(), &[42, 100, 200]);
176    ///
177    /// // 2) &[T]
178    /// let mut mv = MultiValues::Empty(DataType::Int32);
179    /// let slice = &[7, 8, 9][..];
180    /// mv.set(slice).unwrap();
181    /// assert_eq!(mv.get_int32s().unwrap(), &[7, 8, 9]);
182    ///
183    /// // 3) Single T
184    /// let mut mv = MultiValues::Empty(DataType::Int32);
185    /// mv.set(42).unwrap();
186    /// assert_eq!(mv.get_int32s().unwrap(), &[42]);
187    ///
188    /// // String example
189    /// let mut mv = MultiValues::Empty(DataType::String);
190    /// mv.set(vec!["hello".to_string(), "world".to_string()]).unwrap();
191    /// assert_eq!(mv.get_strings().unwrap(), &["hello", "world"]);
192    /// ```
193    #[inline]
194    pub fn set<'a, S>(&mut self, values: S) -> ValueResult<()>
195    where
196        S: MultiValuesSetArg<'a>,
197        Self: MultiValuesSetter<S::Item>
198            + MultiValuesSetterSlice<S::Item>
199            + MultiValuesSingleSetter<S::Item>,
200    {
201        values.apply(self)
202    }
203
204    /// Generic add method
205    ///
206    /// Automatically selects the optimal add path based on the input type,
207    /// appending elements to the existing list with strict type checking.
208    ///
209    /// Supports three input forms:
210    ///
211    /// - `T`: Takes `add_value(T)` path, appending a single element
212    /// - `Vec<T>`: Takes `add_values(Vec<T>)` path, batch append (zero additional allocation)
213    /// - `&[T]`: Takes `add_values_slice(&[T])` path, batch append (using slice)
214    ///
215    /// # Type Parameters
216    ///
217    /// * `S` - Input type, can be a single `T`, `Vec<T>`, or `&[T]`
218    ///
219    /// # Example
220    ///
221    /// ```rust
222    /// use qubit_common::lang::DataType;
223    /// use qubit_value::MultiValues;
224    ///
225    /// // 1) Single T
226    /// let mut mv = MultiValues::Int32(vec![42]);
227    /// mv.add(100).unwrap();
228    /// assert_eq!(mv.get_int32s().unwrap(), &[42, 100]);
229    ///
230    /// // 2) Vec<T>
231    /// mv.add(vec![200, 300]).unwrap();
232    /// assert_eq!(mv.get_int32s().unwrap(), &[42, 100, 200, 300]);
233    ///
234    /// // 3) &[T]
235    /// let slice = &[400, 500][..];
236    /// mv.add(slice).unwrap();
237    /// assert_eq!(mv.get_int32s().unwrap(), &[42, 100, 200, 300, 400, 500]);
238    /// ```
239    #[inline]
240    pub fn add<'a, S>(&mut self, values: S) -> ValueResult<()>
241    where
242        S: MultiValuesAddArg<'a>,
243        Self: MultiValuesAdder<S::Item> + MultiValuesMultiAdder<S::Item>,
244    {
245        values.apply_add(self)
246    }
247
248    /// Get the data type of the values
249    ///
250    /// # Returns
251    ///
252    /// Returns the data type corresponding to these multiple values
253    ///
254    /// # Example
255    ///
256    /// ```rust
257    /// use qubit_common::lang::DataType;
258    /// use qubit_value::MultiValues;
259    ///
260    /// let values = MultiValues::Int32(vec![1, 2, 3]);
261    /// assert_eq!(values.data_type(), DataType::Int32);
262    /// ```
263    #[inline]
264    pub fn data_type(&self) -> DataType {
265        match self {
266            MultiValues::Empty(dt) => *dt,
267            MultiValues::Bool(_) => DataType::Bool,
268            MultiValues::Char(_) => DataType::Char,
269            MultiValues::Int8(_) => DataType::Int8,
270            MultiValues::Int16(_) => DataType::Int16,
271            MultiValues::Int32(_) => DataType::Int32,
272            MultiValues::Int64(_) => DataType::Int64,
273            MultiValues::Int128(_) => DataType::Int128,
274            MultiValues::UInt8(_) => DataType::UInt8,
275            MultiValues::UInt16(_) => DataType::UInt16,
276            MultiValues::UInt32(_) => DataType::UInt32,
277            MultiValues::UInt64(_) => DataType::UInt64,
278            MultiValues::UInt128(_) => DataType::UInt128,
279            MultiValues::Float32(_) => DataType::Float32,
280            MultiValues::Float64(_) => DataType::Float64,
281            MultiValues::String(_) => DataType::String,
282            MultiValues::Date(_) => DataType::Date,
283            MultiValues::Time(_) => DataType::Time,
284            MultiValues::DateTime(_) => DataType::DateTime,
285            MultiValues::Instant(_) => DataType::Instant,
286            MultiValues::BigInteger(_) => DataType::BigInteger,
287            MultiValues::BigDecimal(_) => DataType::BigDecimal,
288            MultiValues::IntSize(_) => DataType::IntSize,
289            MultiValues::UIntSize(_) => DataType::UIntSize,
290            MultiValues::Duration(_) => DataType::Duration,
291            MultiValues::Url(_) => DataType::Url,
292            MultiValues::StringMap(_) => DataType::StringMap,
293            MultiValues::Json(_) => DataType::Json,
294        }
295    }
296
297    /// Get the number of values
298    ///
299    /// # Returns
300    ///
301    /// Returns the number of values contained in these multiple values
302    ///
303    /// # Example
304    ///
305    /// ```rust
306    /// use qubit_common::lang::DataType;
307    /// use qubit_value::MultiValues;
308    ///
309    /// let values = MultiValues::Int32(vec![1, 2, 3]);
310    /// assert_eq!(values.count(), 3);
311    ///
312    /// let empty = MultiValues::Empty(DataType::String);
313    /// assert_eq!(empty.count(), 0);
314    /// ```
315    #[inline]
316    pub fn count(&self) -> usize {
317        match self {
318            MultiValues::Empty(_) => 0,
319            MultiValues::Bool(v) => v.len(),
320            MultiValues::Char(v) => v.len(),
321            MultiValues::Int8(v) => v.len(),
322            MultiValues::Int16(v) => v.len(),
323            MultiValues::Int32(v) => v.len(),
324            MultiValues::Int64(v) => v.len(),
325            MultiValues::Int128(v) => v.len(),
326            MultiValues::UInt8(v) => v.len(),
327            MultiValues::UInt16(v) => v.len(),
328            MultiValues::UInt32(v) => v.len(),
329            MultiValues::UInt64(v) => v.len(),
330            MultiValues::UInt128(v) => v.len(),
331            MultiValues::Float32(v) => v.len(),
332            MultiValues::Float64(v) => v.len(),
333            MultiValues::String(v) => v.len(),
334            MultiValues::Date(v) => v.len(),
335            MultiValues::Time(v) => v.len(),
336            MultiValues::DateTime(v) => v.len(),
337            MultiValues::Instant(v) => v.len(),
338            MultiValues::BigInteger(v) => v.len(),
339            MultiValues::BigDecimal(v) => v.len(),
340            MultiValues::IntSize(v) => v.len(),
341            MultiValues::UIntSize(v) => v.len(),
342            MultiValues::Duration(v) => v.len(),
343            MultiValues::Url(v) => v.len(),
344            MultiValues::StringMap(v) => v.len(),
345            MultiValues::Json(v) => v.len(),
346        }
347    }
348
349    /// Check if empty
350    ///
351    /// # Returns
352    ///
353    /// Returns `true` if these multiple values do not contain any values
354    ///
355    /// # Example
356    ///
357    /// ```rust
358    /// use qubit_common::lang::DataType;
359    /// use qubit_value::MultiValues;
360    ///
361    /// let values = MultiValues::Int32(vec![]);
362    /// assert!(values.is_empty());
363    ///
364    /// let empty = MultiValues::Empty(DataType::String);
365    /// assert!(empty.is_empty());
366    /// ```
367    #[inline]
368    pub fn is_empty(&self) -> bool {
369        self.count() == 0
370    }
371
372    /// Clear all values while preserving the type
373    ///
374    /// # Example
375    ///
376    /// ```rust
377    /// use qubit_common::lang::DataType;
378    /// use qubit_value::MultiValues;
379    ///
380    /// let mut values = MultiValues::Int32(vec![1, 2, 3]);
381    /// values.clear();
382    /// assert!(values.is_empty());
383    /// assert_eq!(values.data_type(), DataType::Int32);
384    /// ```
385    #[inline]
386    pub fn clear(&mut self) {
387        match self {
388            MultiValues::Empty(_) => {}
389            MultiValues::Bool(v) => v.clear(),
390            MultiValues::Char(v) => v.clear(),
391            MultiValues::Int8(v) => v.clear(),
392            MultiValues::Int16(v) => v.clear(),
393            MultiValues::Int32(v) => v.clear(),
394            MultiValues::Int64(v) => v.clear(),
395            MultiValues::Int128(v) => v.clear(),
396            MultiValues::UInt8(v) => v.clear(),
397            MultiValues::UInt16(v) => v.clear(),
398            MultiValues::UInt32(v) => v.clear(),
399            MultiValues::UInt64(v) => v.clear(),
400            MultiValues::UInt128(v) => v.clear(),
401            MultiValues::Float32(v) => v.clear(),
402            MultiValues::Float64(v) => v.clear(),
403            MultiValues::String(v) => v.clear(),
404            MultiValues::Date(v) => v.clear(),
405            MultiValues::Time(v) => v.clear(),
406            MultiValues::DateTime(v) => v.clear(),
407            MultiValues::Instant(v) => v.clear(),
408            MultiValues::BigInteger(v) => v.clear(),
409            MultiValues::BigDecimal(v) => v.clear(),
410            MultiValues::IntSize(v) => v.clear(),
411            MultiValues::UIntSize(v) => v.clear(),
412            MultiValues::Duration(v) => v.clear(),
413            MultiValues::Url(v) => v.clear(),
414            MultiValues::StringMap(v) => v.clear(),
415            MultiValues::Json(v) => v.clear(),
416        }
417    }
418
419    /// Set the data type
420    ///
421    /// If the new type differs from the current type, clears all values and
422    /// sets the new type.
423    ///
424    /// # Parameters
425    ///
426    /// * `data_type` - The data type to set
427    ///
428    /// # Example
429    ///
430    /// ```rust
431    /// use qubit_common::lang::DataType;
432    /// use qubit_value::MultiValues;
433    ///
434    /// let mut values = MultiValues::Int32(vec![1, 2, 3]);
435    /// values.set_type(DataType::String);
436    /// assert!(values.is_empty());
437    /// assert_eq!(values.data_type(), DataType::String);
438    /// ```
439    #[inline]
440    pub fn set_type(&mut self, data_type: DataType) {
441        if self.data_type() != data_type {
442            *self = MultiValues::Empty(data_type);
443        }
444    }
445
446    // ========================================================================
447    // Get first value (as single value access)
448    // ========================================================================
449
450    impl_get_first_value! {
451        /// Get the first boolean value.
452        ///
453        /// # Returns
454        ///
455        /// If types match and a value exists, returns the first boolean value;
456        /// otherwise returns an error.
457        ///
458        /// # Example
459        ///
460        /// ```rust
461        /// use qubit_value::MultiValues;
462        ///
463        /// let values = MultiValues::Bool(vec![true, false]);
464        /// assert_eq!(values.get_first_bool().unwrap(), true);
465        /// ```
466        copy: get_first_bool, Bool, bool, DataType::Bool
467    }
468
469    impl_get_first_value! {
470        /// Get the first character value
471        ///
472        /// # Returns
473        ///
474        /// If types match and a value exists, returns the first character value;
475        /// otherwise returns an error.
476        copy: get_first_char, Char, char, DataType::Char
477    }
478
479    impl_get_first_value! {
480        /// Get the first int8 value
481        ///
482        /// # Returns
483        ///
484        /// If types match and a value exists, returns the first int8 value;
485        /// otherwise returns an error
486        copy: get_first_int8, Int8, i8, DataType::Int8
487    }
488
489    impl_get_first_value! {
490        /// Get the first int16 value
491        ///
492        /// # Returns
493        ///
494        /// If types match and a value exists, returns the first int16 value;
495        /// otherwise returns an error
496        copy: get_first_int16, Int16, i16, DataType::Int16
497    }
498
499    impl_get_first_value! {
500        /// Get the first int32 value
501        ///
502        /// # Returns
503        ///
504        /// If types match and a value exists, returns the first int32 value;
505        /// otherwise returns an error
506        copy: get_first_int32, Int32, i32, DataType::Int32
507    }
508
509    impl_get_first_value! {
510        /// Get the first int64 value
511        ///
512        /// # Returns
513        ///
514        /// If types match and a value exists, returns the first int64 value;
515        /// otherwise returns an error
516        copy: get_first_int64, Int64, i64, DataType::Int64
517    }
518
519    impl_get_first_value! {
520        /// Get the first int128 value
521        ///
522        /// # Returns
523        ///
524        /// If types match and a value exists, returns the first int128 value;
525        /// otherwise returns an error
526        copy: get_first_int128, Int128, i128, DataType::Int128
527    }
528
529    impl_get_first_value! {
530        /// Get the first uint8 value
531        ///
532        /// # Returns
533        ///
534        /// If types match and a value exists, returns the first uint8 value;
535        /// otherwise returns an error
536        copy: get_first_uint8, UInt8, u8, DataType::UInt8
537    }
538
539    impl_get_first_value! {
540        /// Get the first uint16 value
541        ///
542        /// # Returns
543        ///
544        /// If types match and a value exists, returns the first uint16 value;
545        /// otherwise returns an error
546        copy: get_first_uint16, UInt16, u16, DataType::UInt16
547    }
548
549    impl_get_first_value! {
550        /// Get the first uint32 value
551        ///
552        /// # Returns
553        ///
554        /// If types match and a value exists, returns the first uint32 value;
555        /// otherwise returns an error
556        copy: get_first_uint32, UInt32, u32, DataType::UInt32
557    }
558
559    impl_get_first_value! {
560        /// Get the first uint64 value
561        ///
562        /// # Returns
563        ///
564        /// If types match and a value exists, returns the first uint64 value;
565        /// otherwise returns an error
566        copy: get_first_uint64, UInt64, u64, DataType::UInt64
567    }
568
569    impl_get_first_value! {
570        /// Get the first uint128 value
571        ///
572        /// # Returns
573        ///
574        /// If types match and a value exists, returns the first uint128 value;
575        /// otherwise returns an error
576        copy: get_first_uint128, UInt128, u128, DataType::UInt128
577    }
578
579    impl_get_first_value! {
580        /// Get the first float32 value
581        ///
582        /// # Returns
583        ///
584        /// If types match and a value exists, returns the first float32 value;
585        /// otherwise returns an error
586        copy: get_first_float32, Float32, f32, DataType::Float32
587    }
588
589    impl_get_first_value! {
590        /// Get the first float64 value
591        ///
592        /// # Returns
593        ///
594        /// If types match and a value exists, returns the first float64 value;
595        /// otherwise returns an error
596        copy: get_first_float64, Float64, f64, DataType::Float64
597    }
598
599    impl_get_first_value! {
600        /// Get the first string reference
601        ///
602        /// # Returns
603        ///
604        /// If types match and a value exists, returns a reference to the first
605        /// string; otherwise returns an error
606        ref: get_first_string, String, &str, DataType::String, |s: &String| s.as_str()
607    }
608
609    impl_get_first_value! {
610        /// Get the first date value
611        ///
612        /// # Returns
613        ///
614        /// If types match and a value exists, returns the first date value;
615        /// otherwise returns an error
616        copy: get_first_date, Date, NaiveDate, DataType::Date
617    }
618
619    impl_get_first_value! {
620        /// Get the first time value
621        ///
622        /// # Returns
623        ///
624        /// If types match and a value exists, returns the first time value;
625        /// otherwise returns an error
626        copy: get_first_time, Time, NaiveTime, DataType::Time
627    }
628
629    impl_get_first_value! {
630        /// Get the first datetime value
631        ///
632        /// # Returns
633        ///
634        /// If types match and a value exists, returns the first datetime value;
635        /// otherwise returns an error
636        copy: get_first_datetime, DateTime, NaiveDateTime, DataType::DateTime
637    }
638
639    impl_get_first_value! {
640        /// Get the first UTC instant value
641        ///
642        /// # Returns
643        ///
644        /// If types match and a value exists, returns the first UTC instant
645        /// value; otherwise returns an error
646        copy: get_first_instant, Instant, DateTime<Utc>, DataType::Instant
647    }
648
649    impl_get_first_value! {
650        /// Get the first big integer value
651        ///
652        /// # Returns
653        ///
654        /// If types match and a value exists, returns the first big integer
655        /// value; otherwise returns an error
656        ref: get_first_biginteger, BigInteger, BigInt, DataType::BigInteger, |v: &BigInt| v.clone()
657    }
658
659    impl_get_first_value! {
660        /// Get the first big decimal value
661        ///
662        /// # Returns
663        ///
664        /// If types match and a value exists, returns the first big decimal
665        /// value; otherwise returns an error
666        ref: get_first_bigdecimal, BigDecimal, BigDecimal, DataType::BigDecimal, |v: &BigDecimal| v.clone()
667    }
668
669    impl_get_first_value! {
670        /// Get the first isize value
671        copy: get_first_intsize, IntSize, isize, DataType::IntSize
672    }
673
674    impl_get_first_value! {
675        /// Get the first usize value
676        copy: get_first_uintsize, UIntSize, usize, DataType::UIntSize
677    }
678
679    impl_get_first_value! {
680        /// Get the first Duration value
681        copy: get_first_duration, Duration, Duration, DataType::Duration
682    }
683
684    impl_get_first_value! {
685        /// Get the first Url value
686        ref: get_first_url, Url, Url, DataType::Url, |v: &Url| v.clone()
687    }
688
689    impl_get_first_value! {
690        /// Get the first StringMap value
691        ref: get_first_string_map, StringMap, HashMap<String, String>, DataType::StringMap, |v: &HashMap<String, String>| v.clone()
692    }
693
694    impl_get_first_value! {
695        /// Get the first Json value
696        ref: get_first_json, Json, serde_json::Value, DataType::Json, |v: &serde_json::Value| v.clone()
697    }
698
699    // ========================================================================
700    // Get all values (type checking)
701    // ========================================================================
702
703    impl_get_multi_values! {
704        /// Get reference to all boolean values
705        ///
706        /// # Returns
707        ///
708        /// If types match, returns a reference to the boolean value array;
709        /// otherwise returns an error
710        ///
711        /// # Example
712        ///
713        /// ```rust
714        /// use qubit_value::MultiValues;
715        ///
716        /// let values = MultiValues::Bool(vec![true, false, true]);
717        /// assert_eq!(values.get_bools().unwrap(), &[true, false, true]);
718        /// ```
719        slice: get_bools, Bool, bool, DataType::Bool
720    }
721
722    impl_get_multi_values! {
723        /// Get reference to all character values
724        ///
725        /// # Returns
726        ///
727        /// If types match, returns a reference to the character value array;
728        /// otherwise returns an error
729        slice: get_chars, Char, char, DataType::Char
730    }
731
732    impl_get_multi_values! {
733        /// Get reference to all int8 values
734        ///
735        /// # Returns
736        ///
737        /// If types match, returns a reference to the int8 value array;
738        /// otherwise returns an error
739        slice: get_int8s, Int8, i8, DataType::Int8
740    }
741
742    impl_get_multi_values! {
743        /// Get reference to all int16 values
744        ///
745        /// # Returns
746        ///
747        /// If types match, returns a reference to the int16 value array;
748        /// otherwise returns an error
749        slice: get_int16s, Int16, i16, DataType::Int16
750    }
751
752    impl_get_multi_values! {
753        /// Get reference to all int32 values
754        ///
755        /// # Returns
756        ///
757        /// If types match, returns a reference to the int32 value array;
758        /// otherwise returns an error
759        slice: get_int32s, Int32, i32, DataType::Int32
760    }
761
762    impl_get_multi_values! {
763        /// Get reference to all int64 values
764        ///
765        /// # Returns
766        ///
767        /// If types match, returns a reference to the int64 value array;
768        /// otherwise returns an error
769        slice: get_int64s, Int64, i64, DataType::Int64
770    }
771
772    impl_get_multi_values! {
773        /// Get reference to all int128 values
774        ///
775        /// # Returns
776        ///
777        /// If types match, returns a reference to the int128 value array;
778        /// otherwise returns an error
779        slice: get_int128s, Int128, i128, DataType::Int128
780    }
781
782    impl_get_multi_values! {
783        /// Get reference to all uint8 values
784        ///
785        /// # Returns
786        ///
787        /// If types match, returns a reference to the uint8 value array;
788        /// otherwise returns an error
789        slice: get_uint8s, UInt8, u8, DataType::UInt8
790    }
791
792    impl_get_multi_values! {
793        /// Get reference to all uint16 values
794        ///
795        /// # Returns
796        ///
797        /// If types match, returns a reference to the uint16 value array;
798        /// otherwise returns an error
799        slice: get_uint16s, UInt16, u16, DataType::UInt16
800    }
801
802    impl_get_multi_values! {
803        /// Get reference to all uint32 values
804        ///
805        /// # Returns
806        ///
807        /// If types match, returns a reference to the uint32 value array;
808        /// otherwise returns an error
809        slice: get_uint32s, UInt32, u32, DataType::UInt32
810    }
811
812    impl_get_multi_values! {
813        /// Get reference to all uint64 values
814        ///
815        /// # Returns
816        ///
817        /// If types match, returns a reference to the uint64 value array;
818        /// otherwise returns an error
819        slice: get_uint64s, UInt64, u64, DataType::UInt64
820    }
821
822    impl_get_multi_values! {
823        /// Get reference to all uint128 values
824        ///
825        /// # Returns
826        ///
827        /// If types match, returns a reference to the uint128 value array;
828        /// otherwise returns an error
829        slice: get_uint128s, UInt128, u128, DataType::UInt128
830    }
831
832    impl_get_multi_values! {
833        /// Get reference to all float32 values
834        ///
835        /// # Returns
836        ///
837        /// If types match, returns a reference to the float32 value array;
838        /// otherwise returns an error
839        slice: get_float32s, Float32, f32, DataType::Float32
840    }
841
842    impl_get_multi_values! {
843        /// Get reference to all float64 values
844        ///
845        /// # Returns
846        ///
847        /// If types match, returns a reference to the float64 value array;
848        /// otherwise returns an error
849        slice: get_float64s, Float64, f64, DataType::Float64
850    }
851
852    impl_get_multi_values! {
853        /// Get reference to all strings
854        ///
855        /// # Returns
856        ///
857        /// If types match, returns a reference to the string array; otherwise
858        /// returns an error
859        vec: get_strings, String, String, DataType::String
860    }
861
862    impl_get_multi_values! {
863        /// Get reference to all date values
864        ///
865        /// # Returns
866        ///
867        /// If types match, returns a reference to the date value array;
868        /// otherwise returns an error
869        slice: get_dates, Date, NaiveDate, DataType::Date
870    }
871
872    impl_get_multi_values! {
873        /// Get reference to all time values
874        ///
875        /// # Returns
876        ///
877        /// If types match, returns a reference to the time value array;
878        /// otherwise returns an error
879        slice: get_times, Time, NaiveTime, DataType::Time
880    }
881
882    impl_get_multi_values! {
883        /// Get reference to all datetime values
884        ///
885        /// # Returns
886        ///
887        /// If types match, returns a reference to the datetime value array;
888        /// otherwise returns an error
889        slice: get_datetimes, DateTime, NaiveDateTime, DataType::DateTime
890    }
891
892    impl_get_multi_values! {
893        /// Get reference to all UTC instant values
894        ///
895        /// # Returns
896        ///
897        /// If types match, returns a reference to the UTC instant value array;
898        /// otherwise returns an error
899        slice: get_instants, Instant, DateTime<Utc>, DataType::Instant
900    }
901
902    impl_get_multi_values! {
903        /// Get reference to all big integers
904        ///
905        /// # Returns
906        ///
907        /// If types match, returns a reference to the big integer array;
908        /// otherwise returns an error
909        vec: get_bigintegers, BigInteger, BigInt, DataType::BigInteger
910    }
911
912    impl_get_multi_values! {
913        /// Get reference to all big decimals
914        ///
915        /// # Returns
916        ///
917        /// If types match, returns a reference to the big decimal array;
918        /// otherwise returns an error
919        vec: get_bigdecimals, BigDecimal, BigDecimal, DataType::BigDecimal
920    }
921
922    impl_get_multi_values! {
923        /// Get reference to all isize values
924        slice: get_intsizes, IntSize, isize, DataType::IntSize
925    }
926
927    impl_get_multi_values! {
928        /// Get reference to all usize values
929        slice: get_uintsizes, UIntSize, usize, DataType::UIntSize
930    }
931
932    impl_get_multi_values! {
933        /// Get reference to all Duration values
934        slice: get_durations, Duration, Duration, DataType::Duration
935    }
936
937    impl_get_multi_values! {
938        /// Get reference to all Url values
939        vec: get_urls, Url, Url, DataType::Url
940    }
941
942    impl_get_multi_values! {
943        /// Get reference to all StringMap values
944        vec: get_string_maps, StringMap, HashMap<String, String>, DataType::StringMap
945    }
946
947    impl_get_multi_values! {
948        /// Get reference to all Json values
949        vec: get_jsons, Json, serde_json::Value, DataType::Json
950    }
951
952    // ========================================================================
953    // Set value operations
954    // ========================================================================
955
956    impl_set_multi_values! {
957        /// Set all boolean values
958        ///
959        /// # Parameters
960        ///
961        /// * `values` - The list of boolean values to set
962        ///
963        /// # Returns
964        ///
965        /// If setting succeeds, returns `Ok(())`; otherwise returns an error
966        ///
967        /// # Example
968        ///
969        /// ```rust
970        /// use qubit_common::lang::DataType;
971        /// use qubit_value::MultiValues;
972        ///
973        /// let mut values = MultiValues::Empty(DataType::Bool);
974        /// values.set_bools(vec![true, false, true]).unwrap();
975        /// assert_eq!(values.get_bools().unwrap(), &[true, false, true]);
976        /// ```
977        set_bools, Bool, bool, DataType::Bool
978    }
979
980    impl_set_multi_values! {
981        /// Set all character values
982        ///
983        /// # Parameters
984        ///
985        /// * `values` - The list of character values to set
986        ///
987        /// # Returns
988        ///
989        /// If setting succeeds, returns `Ok(())`; otherwise returns an error
990        set_chars, Char, char, DataType::Char
991    }
992
993    impl_set_multi_values! {
994        /// Set all int8 values
995        ///
996        /// # Parameters
997        ///
998        /// * `values` - The list of int8 values to set
999        ///
1000        /// # Returns
1001        ///
1002        /// If setting succeeds, returns `Ok(())`; otherwise returns an error
1003        set_int8s, Int8, i8, DataType::Int8
1004    }
1005
1006    impl_set_multi_values! {
1007        /// Set all int16 values
1008        ///
1009        /// # Parameters
1010        ///
1011        /// * `values` - The list of int16 values to set
1012        ///
1013        /// # Returns
1014        ///
1015        /// If setting succeeds, returns `Ok(())`; otherwise returns an error
1016        set_int16s, Int16, i16, DataType::Int16
1017    }
1018
1019    impl_set_multi_values! {
1020        /// Set all int32 values
1021        ///
1022        /// # Parameters
1023        ///
1024        /// * `values` - The list of int32 values to set
1025        ///
1026        /// # Returns
1027        ///
1028        /// If setting succeeds, returns `Ok(())`; otherwise returns an error
1029        set_int32s, Int32, i32, DataType::Int32
1030    }
1031
1032    impl_set_multi_values! {
1033        /// Set all int64 values
1034        ///
1035        /// # Parameters
1036        ///
1037        /// * `values` - The list of int64 values to set
1038        ///
1039        /// # Returns
1040        ///
1041        /// If setting succeeds, returns `Ok(())`; otherwise returns an error
1042        set_int64s, Int64, i64, DataType::Int64
1043    }
1044
1045    impl_set_multi_values! {
1046        /// Set all int128 values
1047        ///
1048        /// # Parameters
1049        ///
1050        /// * `values` - The list of int128 values to set
1051        ///
1052        /// # Returns
1053        ///
1054        /// If setting succeeds, returns `Ok(())`; otherwise returns an error
1055        set_int128s, Int128, i128, DataType::Int128
1056    }
1057
1058    impl_set_multi_values! {
1059        /// Set all uint8 values
1060        ///
1061        /// # Parameters
1062        ///
1063        /// * `values` - The list of uint8 values to set
1064        ///
1065        /// # Returns
1066        ///
1067        /// If setting succeeds, returns `Ok(())`; otherwise returns an error
1068        set_uint8s, UInt8, u8, DataType::UInt8
1069    }
1070
1071    impl_set_multi_values! {
1072        /// Set all uint16 values
1073        ///
1074        /// # Parameters
1075        ///
1076        /// * `values` - The list of uint16 values to set
1077        ///
1078        /// # Returns
1079        ///
1080        /// If setting succeeds, returns `Ok(())`; otherwise returns an error
1081        set_uint16s, UInt16, u16, DataType::UInt16
1082    }
1083
1084    impl_set_multi_values! {
1085        /// Set all uint32 values
1086        ///
1087        /// # Parameters
1088        ///
1089        /// * `values` - The list of uint32 values to set
1090        ///
1091        /// # Returns
1092        ///
1093        /// If setting succeeds, returns `Ok(())`; otherwise returns an error
1094        set_uint32s, UInt32, u32, DataType::UInt32
1095    }
1096
1097    impl_set_multi_values! {
1098        /// Set all uint64 values
1099        ///
1100        /// # Parameters
1101        ///
1102        /// * `values` - The list of uint64 values to set
1103        ///
1104        /// # Returns
1105        ///
1106        /// If setting succeeds, returns `Ok(())`; otherwise returns an error
1107        set_uint64s, UInt64, u64, DataType::UInt64
1108    }
1109
1110    impl_set_multi_values! {
1111        /// Set all uint128 values
1112        ///
1113        /// # Parameters
1114        ///
1115        /// * `values` - The list of uint128 values to set
1116        ///
1117        /// # Returns
1118        ///
1119        /// If setting succeeds, returns `Ok(())`; otherwise returns an error
1120        set_uint128s, UInt128, u128, DataType::UInt128
1121    }
1122
1123    impl_set_multi_values! {
1124        /// Set all float32 values
1125        ///
1126        /// # Parameters
1127        ///
1128        /// * `values` - The list of float32 values to set
1129        ///
1130        /// # Returns
1131        ///
1132        /// If setting succeeds, returns `Ok(())`; otherwise returns an error
1133        set_float32s, Float32, f32, DataType::Float32
1134    }
1135
1136    impl_set_multi_values! {
1137        /// Set all float64 values
1138        ///
1139        /// # Parameters
1140        ///
1141        /// * `values` - The list of float64 values to set
1142        ///
1143        /// # Returns
1144        ///
1145        /// If setting succeeds, returns `Ok(())`; otherwise returns an error
1146        set_float64s, Float64, f64, DataType::Float64
1147    }
1148
1149    impl_set_multi_values! {
1150        /// Set all string values
1151        ///
1152        /// # Parameters
1153        ///
1154        /// * `values` - The list of string values to set
1155        ///
1156        /// # Returns
1157        ///
1158        /// If setting succeeds, returns `Ok(())`; otherwise returns an error
1159        ///
1160        /// # Example
1161        ///
1162        /// ```rust
1163        /// use qubit_common::lang::DataType;
1164        /// use qubit_value::MultiValues;
1165        ///
1166        /// let mut values = MultiValues::Empty(DataType::String);
1167        /// values.set_strings(vec!["hello".to_string(), "world".to_string()]).unwrap();
1168        /// assert_eq!(values.get_strings().unwrap(), &["hello", "world"]);
1169        /// ```
1170        set_strings, String, String, DataType::String
1171    }
1172
1173    impl_set_multi_values! {
1174        /// Set all date values
1175        ///
1176        /// # Parameters
1177        ///
1178        /// * `values` - The list of date values to set
1179        ///
1180        /// # Returns
1181        ///
1182        /// If setting succeeds, returns `Ok(())`; otherwise returns an error
1183        set_dates, Date, NaiveDate, DataType::Date
1184    }
1185
1186    impl_set_multi_values! {
1187        /// Set all time values
1188        ///
1189        /// # Parameters
1190        ///
1191        /// * `values` - The list of time values to set
1192        ///
1193        /// # Returns
1194        ///
1195        /// If setting succeeds, returns `Ok(())`; otherwise returns an error
1196        set_times, Time, NaiveTime, DataType::Time
1197    }
1198
1199    impl_set_multi_values! {
1200        /// Set all datetime values
1201        ///
1202        /// # Parameters
1203        ///
1204        /// * `values` - The list of datetime values to set
1205        ///
1206        /// # Returns
1207        ///
1208        /// If setting succeeds, returns `Ok(())`; otherwise returns an error
1209        set_datetimes, DateTime, NaiveDateTime, DataType::DateTime
1210    }
1211
1212    impl_set_multi_values! {
1213        /// Set all UTC instant values
1214        ///
1215        /// # Parameters
1216        ///
1217        /// * `values` - The list of UTC instant values to set
1218        ///
1219        /// # Returns
1220        ///
1221        /// If setting succeeds, returns `Ok(())`; otherwise returns an error
1222        set_instants, Instant, DateTime<Utc>, DataType::Instant
1223    }
1224
1225    impl_set_multi_values! {
1226        /// Set all big integer values
1227        ///
1228        /// # Parameters
1229        ///
1230        /// * `values` - The list of big integer values to set
1231        ///
1232        /// # Returns
1233        ///
1234        /// If setting succeeds, returns `Ok(())`; otherwise returns an error
1235        set_bigintegers, BigInteger, BigInt, DataType::BigInteger
1236    }
1237
1238    impl_set_multi_values! {
1239        /// Set all big decimal values
1240        ///
1241        /// # Parameters
1242        ///
1243        /// * `values` - The list of big decimal values to set
1244        ///
1245        /// # Returns
1246        ///
1247        /// If setting succeeds, returns `Ok(())`; otherwise returns an error
1248        set_bigdecimals, BigDecimal, BigDecimal, DataType::BigDecimal
1249    }
1250
1251    impl_set_multi_values! {
1252        /// Set all isize values
1253        set_intsizes, IntSize, isize, DataType::IntSize
1254    }
1255
1256    impl_set_multi_values! {
1257        /// Set all usize values
1258        set_uintsizes, UIntSize, usize, DataType::UIntSize
1259    }
1260
1261    impl_set_multi_values! {
1262        /// Set all Duration values
1263        set_durations, Duration, Duration, DataType::Duration
1264    }
1265
1266    impl_set_multi_values! {
1267        /// Set all Url values
1268        set_urls, Url, Url, DataType::Url
1269    }
1270
1271    impl_set_multi_values! {
1272        /// Set all StringMap values
1273        set_string_maps, StringMap, HashMap<String, String>, DataType::StringMap
1274    }
1275
1276    impl_set_multi_values! {
1277        /// Set all Json values
1278        set_jsons, Json, serde_json::Value, DataType::Json
1279    }
1280
1281    // ========================================================================
1282    // Set all values via slice operations
1283    // ========================================================================
1284
1285    impl_set_multi_values_slice! {
1286        /// Set all boolean values via slice
1287        ///
1288        /// # Parameters
1289        ///
1290        /// * `values` - The boolean value slice to set
1291        ///
1292        /// # Returns
1293        ///
1294        /// If setting succeeds, returns `Ok(())`; otherwise returns an error
1295        set_bools_slice, Bool, bool, DataType::Bool
1296    }
1297
1298    impl_set_multi_values_slice! {
1299        /// Set all character values via slice
1300        ///
1301        /// # Parameters
1302        ///
1303        /// * `values` - The character value slice to set
1304        ///
1305        /// # Returns
1306        ///
1307        /// If setting succeeds, returns `Ok(())`; otherwise returns an error
1308        set_chars_slice, Char, char, DataType::Char
1309    }
1310
1311    impl_set_multi_values_slice! {
1312        /// Set all int8 values via slice
1313        ///
1314        /// # Parameters
1315        ///
1316        /// * `values` - The int8 value slice to set
1317        ///
1318        /// # Returns
1319        ///
1320        /// If setting succeeds, returns `Ok(())`; otherwise returns an error
1321        set_int8s_slice, Int8, i8, DataType::Int8
1322    }
1323
1324    impl_set_multi_values_slice! {
1325        /// Set all int16 values via slice
1326        ///
1327        /// # Parameters
1328        ///
1329        /// * `values` - The int16 value slice to set
1330        ///
1331        /// # Returns
1332        ///
1333        /// If setting succeeds, returns `Ok(())`; otherwise returns an error
1334        set_int16s_slice, Int16, i16, DataType::Int16
1335    }
1336
1337    impl_set_multi_values_slice! {
1338        /// Set all int32 values via slice
1339        ///
1340        /// # Parameters
1341        ///
1342        /// * `values` - The int32 value slice to set
1343        ///
1344        /// # Returns
1345        ///
1346        /// If setting succeeds, returns `Ok(())`; otherwise returns an error
1347        set_int32s_slice, Int32, i32, DataType::Int32
1348    }
1349
1350    impl_set_multi_values_slice! {
1351        /// Set all int64 values via slice
1352        ///
1353        /// # Parameters
1354        ///
1355        /// * `values` - The int64 value slice to set
1356        ///
1357        /// # Returns
1358        ///
1359        /// If setting succeeds, returns `Ok(())`; otherwise returns an error
1360        set_int64s_slice, Int64, i64, DataType::Int64
1361    }
1362
1363    impl_set_multi_values_slice! {
1364        /// Set all int128 values via slice
1365        ///
1366        /// # Parameters
1367        ///
1368        /// * `values` - The int128 value slice to set
1369        ///
1370        /// # Returns
1371        ///
1372        /// If setting succeeds, returns `Ok(())`; otherwise returns an error
1373        set_int128s_slice, Int128, i128, DataType::Int128
1374    }
1375
1376    impl_set_multi_values_slice! {
1377        /// Set all uint8 values via slice
1378        ///
1379        /// # Parameters
1380        ///
1381        /// * `values` - The uint8 value slice to set
1382        ///
1383        /// # Returns
1384        ///
1385        /// If setting succeeds, returns `Ok(())`; otherwise returns an error
1386        set_uint8s_slice, UInt8, u8, DataType::UInt8
1387    }
1388
1389    impl_set_multi_values_slice! {
1390        /// Set all uint16 values via slice
1391        ///
1392        /// # Parameters
1393        ///
1394        /// * `values` - The uint16 value slice to set
1395        ///
1396        /// # Returns
1397        ///
1398        /// If setting succeeds, returns `Ok(())`; otherwise returns an error
1399        set_uint16s_slice, UInt16, u16, DataType::UInt16
1400    }
1401
1402    impl_set_multi_values_slice! {
1403        /// Set all uint32 values via slice
1404        ///
1405        /// # Parameters
1406        ///
1407        /// * `values` - The uint32 value slice to set
1408        ///
1409        /// # Returns
1410        ///
1411        /// If setting succeeds, returns `Ok(())`; otherwise returns an error
1412        set_uint32s_slice, UInt32, u32, DataType::UInt32
1413    }
1414
1415    impl_set_multi_values_slice! {
1416        /// Set all uint64 values via slice
1417        ///
1418        /// # Parameters
1419        ///
1420        /// * `values` - The uint64 value slice to set
1421        ///
1422        /// # Returns
1423        ///
1424        /// If setting succeeds, returns `Ok(())`; otherwise returns an error
1425        set_uint64s_slice, UInt64, u64, DataType::UInt64
1426    }
1427
1428    impl_set_multi_values_slice! {
1429        /// Set all uint128 values via slice
1430        ///
1431        /// # Parameters
1432        ///
1433        /// * `values` - The uint128 value slice to set
1434        ///
1435        /// # Returns
1436        ///
1437        /// If setting succeeds, returns `Ok(())`; otherwise returns an error
1438        set_uint128s_slice, UInt128, u128, DataType::UInt128
1439    }
1440
1441    impl_set_multi_values_slice! {
1442        /// Set all float32 values via slice
1443        ///
1444        /// # Parameters
1445        ///
1446        /// * `values` - The float32 value slice to set
1447        ///
1448        /// # Returns
1449        ///
1450        /// If setting succeeds, returns `Ok(())`; otherwise returns an error
1451        set_float32s_slice, Float32, f32, DataType::Float32
1452    }
1453
1454    impl_set_multi_values_slice! {
1455        /// Set all float64 values via slice
1456        ///
1457        /// # Parameters
1458        ///
1459        /// * `values` - The float64 value slice to set
1460        ///
1461        /// # Returns
1462        ///
1463        /// If setting succeeds, returns `Ok(())`; otherwise returns an error
1464        set_float64s_slice, Float64, f64, DataType::Float64
1465    }
1466
1467    impl_set_multi_values_slice! {
1468        /// Set all string values via slice
1469        ///
1470        /// # Parameters
1471        ///
1472        /// * `values` - The string value slice to set
1473        ///
1474        /// # Returns
1475        ///
1476        /// If setting succeeds, returns `Ok(())`; otherwise returns an error
1477        set_strings_slice, String, String, DataType::String
1478    }
1479
1480    impl_set_multi_values_slice! {
1481        /// Set all date values via slice
1482        ///
1483        /// # Parameters
1484        ///
1485        /// * `values` - The date value slice to set
1486        ///
1487        /// # Returns
1488        ///
1489        /// If setting succeeds, returns `Ok(())`; otherwise returns an error
1490        set_dates_slice, Date, NaiveDate, DataType::Date
1491    }
1492
1493    impl_set_multi_values_slice! {
1494        /// Set all time values via slice
1495        ///
1496        /// # Parameters
1497        ///
1498        /// * `values` - The time value slice to set
1499        ///
1500        /// # Returns
1501        ///
1502        /// If setting succeeds, returns `Ok(())`; otherwise returns an error
1503        set_times_slice, Time, NaiveTime, DataType::Time
1504    }
1505
1506    impl_set_multi_values_slice! {
1507        /// Set all datetime values via slice
1508        ///
1509        /// # Parameters
1510        ///
1511        /// * `values` - The datetime value slice to set
1512        ///
1513        /// # Returns
1514        ///
1515        /// If setting succeeds, returns `Ok(())`; otherwise returns an error
1516        set_datetimes_slice, DateTime, NaiveDateTime, DataType::DateTime
1517    }
1518
1519    impl_set_multi_values_slice! {
1520        /// Set all UTC instant values via slice
1521        ///
1522        /// # Parameters
1523        ///
1524        /// * `values` - The UTC instant value slice to set
1525        ///
1526        /// # Returns
1527        ///
1528        /// If setting succeeds, returns `Ok(())`; otherwise returns an error
1529        set_instants_slice, Instant, DateTime<Utc>, DataType::Instant
1530    }
1531
1532    impl_set_multi_values_slice! {
1533        /// Set all big integer values via slice
1534        ///
1535        /// # Parameters
1536        ///
1537        /// * `values` - The big integer value slice to set
1538        ///
1539        /// # Returns
1540        ///
1541        /// If setting succeeds, returns `Ok(())`; otherwise returns an error
1542        set_bigintegers_slice, BigInteger, BigInt, DataType::BigInteger
1543    }
1544
1545    impl_set_multi_values_slice! {
1546        /// Set all big decimal values via slice
1547        ///
1548        /// # Parameters
1549        ///
1550        /// * `values` - The big decimal value slice to set
1551        ///
1552        /// # Returns
1553        ///
1554        /// If setting succeeds, returns `Ok(())`; otherwise returns an error
1555        set_bigdecimals_slice, BigDecimal, BigDecimal, DataType::BigDecimal
1556    }
1557
1558    impl_set_multi_values_slice! {
1559        /// Set all isize values via slice
1560        set_intsizes_slice, IntSize, isize, DataType::IntSize
1561    }
1562
1563    impl_set_multi_values_slice! {
1564        /// Set all usize values via slice
1565        set_uintsizes_slice, UIntSize, usize, DataType::UIntSize
1566    }
1567
1568    impl_set_multi_values_slice! {
1569        /// Set all Duration values via slice
1570        set_durations_slice, Duration, Duration, DataType::Duration
1571    }
1572
1573    impl_set_multi_values_slice! {
1574        /// Set all Url values via slice
1575        set_urls_slice, Url, Url, DataType::Url
1576    }
1577
1578    impl_set_multi_values_slice! {
1579        /// Set all StringMap values via slice
1580        set_string_maps_slice, StringMap, HashMap<String, String>, DataType::StringMap
1581    }
1582
1583    impl_set_multi_values_slice! {
1584        /// Set all Json values via slice
1585        set_jsons_slice, Json, serde_json::Value, DataType::Json
1586    }
1587
1588    // ========================================================================
1589    // Set single value operations
1590    // ========================================================================
1591
1592    impl_set_single_value! {
1593        /// Set single boolean value
1594        ///
1595        /// # Parameters
1596        ///
1597        /// * `value` - The boolean value to set
1598        ///
1599        /// # Returns
1600        ///
1601        /// If setting succeeds, returns `Ok(())`; otherwise returns an error
1602        ///
1603        /// # Example
1604        ///
1605        /// ```rust
1606        /// use qubit_common::lang::DataType;
1607        /// use qubit_value::MultiValues;
1608        ///
1609        /// let mut values = MultiValues::Empty(DataType::Bool);
1610        /// values.set_bool(true).unwrap();
1611        /// assert_eq!(values.get_bools().unwrap(), &[true]);
1612        /// ```
1613        set_bool, Bool, bool, DataType::Bool
1614    }
1615
1616    impl_set_single_value! {
1617        /// Set single character value
1618        ///
1619        /// # Parameters
1620        ///
1621        /// * `value` - The character value to set
1622        ///
1623        /// # Returns
1624        ///
1625        /// If setting succeeds, returns `Ok(())`; otherwise returns an error
1626        set_char, Char, char, DataType::Char
1627    }
1628
1629    impl_set_single_value! {
1630        /// Set single int8 value
1631        ///
1632        /// # Parameters
1633        ///
1634        /// * `value` - The int8 value to set
1635        ///
1636        /// # Returns
1637        ///
1638        /// If setting succeeds, returns `Ok(())`; otherwise returns an error
1639        set_int8, Int8, i8, DataType::Int8
1640    }
1641
1642    impl_set_single_value! {
1643        /// Set single int16 value
1644        ///
1645        /// # Parameters
1646        ///
1647        /// * `value` - The int16 value to set
1648        ///
1649        /// # Returns
1650        ///
1651        /// If setting succeeds, returns `Ok(())`; otherwise returns an error
1652        set_int16, Int16, i16, DataType::Int16
1653    }
1654
1655    impl_set_single_value! {
1656        /// Set single int32 value
1657        ///
1658        /// # Parameters
1659        ///
1660        /// * `value` - The int32 value to set
1661        ///
1662        /// # Returns
1663        ///
1664        /// If setting succeeds, returns `Ok(())`; otherwise returns an error
1665        set_int32, Int32, i32, DataType::Int32
1666    }
1667
1668    impl_set_single_value! {
1669        /// Set single int64 value
1670        ///
1671        /// # Parameters
1672        ///
1673        /// * `value` - The int64 value to set
1674        ///
1675        /// # Returns
1676        ///
1677        /// If setting succeeds, returns `Ok(())`; otherwise returns an error
1678        set_int64, Int64, i64, DataType::Int64
1679    }
1680
1681    impl_set_single_value! {
1682        /// Set single int128 value
1683        ///
1684        /// # Parameters
1685        ///
1686        /// * `value` - The int128 value to set
1687        ///
1688        /// # Returns
1689        ///
1690        /// If setting succeeds, returns `Ok(())`; otherwise returns an error
1691        set_int128, Int128, i128, DataType::Int128
1692    }
1693
1694    impl_set_single_value! {
1695        /// Set single uint8 value
1696        ///
1697        /// # Parameters
1698        ///
1699        /// * `value` - The uint8 value to set
1700        ///
1701        /// # Returns
1702        ///
1703        /// If setting succeeds, returns `Ok(())`; otherwise returns an error
1704        set_uint8, UInt8, u8, DataType::UInt8
1705    }
1706
1707    impl_set_single_value! {
1708        /// Set single uint16 value
1709        ///
1710        /// # Parameters
1711        ///
1712        /// * `value` - The uint16 value to set
1713        ///
1714        /// # Returns
1715        ///
1716        /// If setting succeeds, returns `Ok(())`; otherwise returns an error
1717        set_uint16, UInt16, u16, DataType::UInt16
1718    }
1719
1720    impl_set_single_value! {
1721        /// Set single uint32 value
1722        ///
1723        /// # Parameters
1724        ///
1725        /// * `value` - The uint32 value to set
1726        ///
1727        /// # Returns
1728        ///
1729        /// If setting succeeds, returns `Ok(())`; otherwise returns an error
1730        set_uint32, UInt32, u32, DataType::UInt32
1731    }
1732
1733    impl_set_single_value! {
1734        /// Set single uint64 value
1735        ///
1736        /// # Parameters
1737        ///
1738        /// * `value` - The uint64 value to set
1739        ///
1740        /// # Returns
1741        ///
1742        /// If setting succeeds, returns `Ok(())`; otherwise returns an error
1743        set_uint64, UInt64, u64, DataType::UInt64
1744    }
1745
1746    impl_set_single_value! {
1747        /// Set single uint128 value
1748        ///
1749        /// # Parameters
1750        ///
1751        /// * `value` - The uint128 value to set
1752        ///
1753        /// # Returns
1754        ///
1755        /// If setting succeeds, returns `Ok(())`; otherwise returns an error
1756        set_uint128, UInt128, u128, DataType::UInt128
1757    }
1758
1759    impl_set_single_value! {
1760        /// Set single float32 value
1761        ///
1762        /// # Parameters
1763        ///
1764        /// * `value` - The float32 value to set
1765        ///
1766        /// # Returns
1767        ///
1768        /// If setting succeeds, returns `Ok(())`; otherwise returns an error
1769        set_float32, Float32, f32, DataType::Float32
1770    }
1771
1772    impl_set_single_value! {
1773        /// Set single float64 value
1774        ///
1775        /// # Parameters
1776        ///
1777        /// * `value` - The float64 value to set
1778        ///
1779        /// # Returns
1780        ///
1781        /// If setting succeeds, returns `Ok(())`; otherwise returns an error
1782        set_float64, Float64, f64, DataType::Float64
1783    }
1784
1785    impl_set_single_value! {
1786        /// Set single string value
1787        ///
1788        /// # Parameters
1789        ///
1790        /// * `value` - The string value to set
1791        ///
1792        /// # Returns
1793        ///
1794        /// If setting succeeds, returns `Ok(())`; otherwise returns an error
1795        ///
1796        /// # Example
1797        ///
1798        /// ```rust
1799        /// use qubit_common::lang::DataType;
1800        /// use qubit_value::MultiValues;
1801        ///
1802        /// let mut values = MultiValues::Empty(DataType::String);
1803        /// values.set_string("hello".to_string()).unwrap();
1804        /// assert_eq!(values.get_strings().unwrap(), &["hello"]);
1805        /// ```
1806        set_string, String, String, DataType::String
1807    }
1808
1809    impl_set_single_value! {
1810        /// Set single date value
1811        ///
1812        /// # Parameters
1813        ///
1814        /// * `value` - The date value to set
1815        ///
1816        /// # Returns
1817        ///
1818        /// If setting succeeds, returns `Ok(())`; otherwise returns an error
1819        set_date, Date, NaiveDate, DataType::Date
1820    }
1821
1822    impl_set_single_value! {
1823        /// Set single time value
1824        ///
1825        /// # Parameters
1826        ///
1827        /// * `value` - The time value to set
1828        ///
1829        /// # Returns
1830        ///
1831        /// If setting succeeds, returns `Ok(())`; otherwise returns an error
1832        set_time, Time, NaiveTime, DataType::Time
1833    }
1834
1835    impl_set_single_value! {
1836        /// Set single datetime value
1837        ///
1838        /// # Parameters
1839        ///
1840        /// * `value` - The datetime value to set
1841        ///
1842        /// # Returns
1843        ///
1844        /// If setting succeeds, returns `Ok(())`; otherwise returns an error
1845        set_datetime, DateTime, NaiveDateTime, DataType::DateTime
1846    }
1847
1848    impl_set_single_value! {
1849        /// Set single UTC instant value
1850        ///
1851        /// # Parameters
1852        ///
1853        /// * `value` - The UTC instant value to set
1854        ///
1855        /// # Returns
1856        ///
1857        /// If setting succeeds, returns `Ok(())`; otherwise returns an error
1858        set_instant, Instant, DateTime<Utc>, DataType::Instant
1859    }
1860
1861    impl_set_single_value! {
1862        /// Set single big integer value
1863        ///
1864        /// # Parameters
1865        ///
1866        /// * `value` - The big integer value to set
1867        ///
1868        /// # Returns
1869        ///
1870        /// If setting succeeds, returns `Ok(())`; otherwise returns an error
1871        set_biginteger, BigInteger, BigInt, DataType::BigInteger
1872    }
1873
1874    impl_set_single_value! {
1875        /// Set single big decimal value
1876        ///
1877        /// # Parameters
1878        ///
1879        /// * `value` - The big decimal value to set
1880        ///
1881        /// # Returns
1882        ///
1883        /// If setting succeeds, returns `Ok(())`; otherwise returns an error
1884        set_bigdecimal, BigDecimal, BigDecimal, DataType::BigDecimal
1885    }
1886
1887    impl_set_single_value! {
1888        /// Set single isize value
1889        set_intsize, IntSize, isize, DataType::IntSize
1890    }
1891
1892    impl_set_single_value! {
1893        /// Set single usize value
1894        set_uintsize, UIntSize, usize, DataType::UIntSize
1895    }
1896
1897    impl_set_single_value! {
1898        /// Set single Duration value
1899        set_duration, Duration, Duration, DataType::Duration
1900    }
1901
1902    impl_set_single_value! {
1903        /// Set single Url value
1904        set_url, Url, Url, DataType::Url
1905    }
1906
1907    impl_set_single_value! {
1908        /// Set single StringMap value
1909        set_string_map, StringMap, HashMap<String, String>, DataType::StringMap
1910    }
1911
1912    impl_set_single_value! {
1913        /// Set single Json value
1914        set_json, Json, serde_json::Value, DataType::Json
1915    }
1916
1917    // ========================================================================
1918    // Add value operations
1919    // ========================================================================
1920
1921    impl_add_single_value! {
1922        /// Add a boolean value
1923        ///
1924        /// # Parameters
1925        ///
1926        /// * `value` - The boolean value to add
1927        ///
1928        /// # Returns
1929        ///
1930        /// If types match, returns `Ok(())`; otherwise returns an error
1931        ///
1932        /// # Example
1933        ///
1934        /// ```rust
1935        /// use qubit_value::MultiValues;
1936        ///
1937        /// let mut values = MultiValues::Bool(vec![true]);
1938        /// values.add_bool(false).unwrap();
1939        /// assert_eq!(values.count(), 2);
1940        /// ```
1941        add_bool, Bool, bool, DataType::Bool
1942    }
1943
1944    impl_add_single_value! {
1945        /// Add a character value
1946        ///
1947        /// # Parameters
1948        ///
1949        /// * `value` - The character value to add
1950        ///
1951        /// # Returns
1952        ///
1953        /// If types match, returns `Ok(())`; otherwise returns an error
1954        add_char, Char, char, DataType::Char
1955    }
1956
1957    impl_add_single_value! {
1958        /// Add an int8 value
1959        ///
1960        /// # Parameters
1961        ///
1962        /// * `value` - The int8 value to add
1963        ///
1964        /// # Returns
1965        ///
1966        /// If types match, returns `Ok(())`; otherwise returns an error
1967        add_int8, Int8, i8, DataType::Int8
1968    }
1969
1970    impl_add_single_value! {
1971        /// Add an int16 value
1972        ///
1973        /// # Parameters
1974        ///
1975        /// * `value` - The int16 value to add
1976        ///
1977        /// # Returns
1978        ///
1979        /// If types match, returns `Ok(())`; otherwise returns an error
1980        add_int16, Int16, i16, DataType::Int16
1981    }
1982
1983    impl_add_single_value! {
1984        /// Add an int32 value
1985        ///
1986        /// # Parameters
1987        ///
1988        /// * `value` - The int32 value to add
1989        ///
1990        /// # Returns
1991        ///
1992        /// If types match, returns `Ok(())`; otherwise returns an error
1993        add_int32, Int32, i32, DataType::Int32
1994    }
1995
1996    impl_add_single_value! {
1997        /// Add an int64 value
1998        ///
1999        /// # Parameters
2000        ///
2001        /// * `value` - The int64 value to add
2002        ///
2003        /// # Returns
2004        ///
2005        /// If types match, returns `Ok(())`; otherwise returns an error
2006        add_int64, Int64, i64, DataType::Int64
2007    }
2008
2009    impl_add_single_value! {
2010        /// Add an int128 value
2011        ///
2012        /// # Parameters
2013        ///
2014        /// * `value` - The int128 value to add
2015        ///
2016        /// # Returns
2017        ///
2018        /// If types match, returns `Ok(())`; otherwise returns an error
2019        add_int128, Int128, i128, DataType::Int128
2020    }
2021
2022    impl_add_single_value! {
2023        /// Add a uint8 value
2024        ///
2025        /// # Parameters
2026        ///
2027        /// * `value` - The uint8 value to add
2028        ///
2029        /// # Returns
2030        ///
2031        /// If types match, returns `Ok(())`; otherwise returns an error
2032        add_uint8, UInt8, u8, DataType::UInt8
2033    }
2034
2035    impl_add_single_value! {
2036        /// Add a uint16 value
2037        ///
2038        /// # Parameters
2039        ///
2040        /// * `value` - The uint16 value to add
2041        ///
2042        /// # Returns
2043        ///
2044        /// If types match, returns `Ok(())`; otherwise returns an error
2045        add_uint16, UInt16, u16, DataType::UInt16
2046    }
2047
2048    impl_add_single_value! {
2049        /// Add a uint32 value
2050        ///
2051        /// # Parameters
2052        ///
2053        /// * `value` - The uint32 value to add
2054        ///
2055        /// # Returns
2056        ///
2057        /// If types match, returns `Ok(())`; otherwise returns an error
2058        add_uint32, UInt32, u32, DataType::UInt32
2059    }
2060
2061    impl_add_single_value! {
2062        /// Add a uint64 value
2063        ///
2064        /// # Parameters
2065        ///
2066        /// * `value` - The uint64 value to add
2067        ///
2068        /// # Returns
2069        ///
2070        /// If types match, returns `Ok(())`; otherwise returns an error
2071        add_uint64, UInt64, u64, DataType::UInt64
2072    }
2073
2074    impl_add_single_value! {
2075        /// Add a uint128 value
2076        ///
2077        /// # Parameters
2078        ///
2079        /// * `value` - The uint128 value to add
2080        ///
2081        /// # Returns
2082        ///
2083        /// If types match, returns `Ok(())`; otherwise returns an error
2084        add_uint128, UInt128, u128, DataType::UInt128
2085    }
2086
2087    impl_add_single_value! {
2088        /// Add a float32 value
2089        ///
2090        /// # Parameters
2091        ///
2092        /// * `value` - The float32 value to add
2093        ///
2094        /// # Returns
2095        ///
2096        /// If types match, returns `Ok(())`; otherwise returns an error
2097        add_float32, Float32, f32, DataType::Float32
2098    }
2099
2100    impl_add_single_value! {
2101        /// Add a float64 value
2102        ///
2103        /// # Parameters
2104        ///
2105        /// * `value` - The float64 value to add
2106        ///
2107        /// # Returns
2108        ///
2109        /// If types match, returns `Ok(())`; otherwise returns an error
2110        add_float64, Float64, f64, DataType::Float64
2111    }
2112
2113    impl_add_single_value! {
2114        /// Add a string
2115        ///
2116        /// # Parameters
2117        ///
2118        /// * `value` - The string to add
2119        ///
2120        /// # Returns
2121        ///
2122        /// If types match, returns `Ok(())`; otherwise returns an error
2123        add_string, String, String, DataType::String
2124    }
2125
2126    impl_add_single_value! {
2127        /// Add a date value
2128        ///
2129        /// # Parameters
2130        ///
2131        /// * `value` - The date value to add
2132        ///
2133        /// # Returns
2134        ///
2135        /// If types match, returns `Ok(())`; otherwise returns an error
2136        add_date, Date, NaiveDate, DataType::Date
2137    }
2138
2139    impl_add_single_value! {
2140        /// Add a time value
2141        ///
2142        /// # Parameters
2143        ///
2144        /// * `value` - The time value to add
2145        ///
2146        /// # Returns
2147        ///
2148        /// If types match, returns `Ok(())`; otherwise returns an error
2149        add_time, Time, NaiveTime, DataType::Time
2150    }
2151
2152    impl_add_single_value! {
2153        /// Add a datetime value
2154        ///
2155        /// # Parameters
2156        ///
2157        /// * `value` - The datetime value to add
2158        ///
2159        /// # Returns
2160        ///
2161        /// If types match, returns `Ok(())`; otherwise returns an error
2162        add_datetime, DateTime, NaiveDateTime, DataType::DateTime
2163    }
2164
2165    impl_add_single_value! {
2166        /// Add a UTC instant value
2167        ///
2168        /// # Parameters
2169        ///
2170        /// * `value` - The UTC instant value to add
2171        ///
2172        /// # Returns
2173        ///
2174        /// If types match, returns `Ok(())`; otherwise returns an error
2175        add_instant, Instant, DateTime<Utc>, DataType::Instant
2176    }
2177
2178    impl_add_single_value! {
2179        /// Add a big integer value
2180        ///
2181        /// # Parameters
2182        ///
2183        /// * `value` - The big integer value to add
2184        ///
2185        /// # Returns
2186        ///
2187        /// If types match, returns `Ok(())`; otherwise returns an error
2188        add_biginteger, BigInteger, BigInt, DataType::BigInteger
2189    }
2190
2191    impl_add_single_value! {
2192        /// Add a big decimal value
2193        ///
2194        /// # Parameters
2195        ///
2196        /// * `value` - The big decimal value to add
2197        ///
2198        /// # Returns
2199        ///
2200        /// If types match, returns `Ok(())`; otherwise returns an error
2201        add_bigdecimal, BigDecimal, BigDecimal, DataType::BigDecimal
2202    }
2203
2204    impl_add_single_value! {
2205        /// Add an isize value
2206        add_intsize, IntSize, isize, DataType::IntSize
2207    }
2208
2209    impl_add_single_value! {
2210        /// Add a usize value
2211        add_uintsize, UIntSize, usize, DataType::UIntSize
2212    }
2213
2214    impl_add_single_value! {
2215        /// Add a Duration value
2216        add_duration, Duration, Duration, DataType::Duration
2217    }
2218
2219    impl_add_single_value! {
2220        /// Add a Url value
2221        add_url, Url, Url, DataType::Url
2222    }
2223
2224    impl_add_single_value! {
2225        /// Add a StringMap value
2226        add_string_map, StringMap, HashMap<String, String>, DataType::StringMap
2227    }
2228
2229    impl_add_single_value! {
2230        /// Add a Json value
2231        add_json, Json, serde_json::Value, DataType::Json
2232    }
2233
2234    // ========================================================================
2235    // Add multiple values operations
2236    // ========================================================================
2237
2238    impl_add_multi_values! {
2239        /// Add multiple boolean values
2240        ///
2241        /// # Parameters
2242        ///
2243        /// * `values` - The list of boolean values to add
2244        ///
2245        /// # Returns
2246        ///
2247        /// If types match, returns `Ok(())`; otherwise returns an error
2248        ///
2249        /// # Example
2250        ///
2251        /// ```rust
2252        /// use qubit_value::MultiValues;
2253        ///
2254        /// let mut values = MultiValues::Bool(vec![true]);
2255        /// values.add_bools(vec![false, true]).unwrap();
2256        /// assert_eq!(values.get_bools().unwrap(), &[true, false, true]);
2257        /// ```
2258        add_bools, Bool, bool, DataType::Bool
2259    }
2260
2261    impl_add_multi_values! {
2262        /// Add multiple character values
2263        ///
2264        /// # Parameters
2265        ///
2266        /// * `values` - The list of character values to add
2267        ///
2268        /// # Returns
2269        ///
2270        /// If types match, returns `Ok(())`; otherwise returns an error
2271        add_chars, Char, char, DataType::Char
2272    }
2273
2274    impl_add_multi_values! {
2275        /// Add multiple int8 values
2276        ///
2277        /// # Parameters
2278        ///
2279        /// * `values` - The list of int8 values to add
2280        ///
2281        /// # Returns
2282        ///
2283        /// If types match, returns `Ok(())`; otherwise returns an error
2284        add_int8s, Int8, i8, DataType::Int8
2285    }
2286
2287    impl_add_multi_values! {
2288        /// Add multiple int16 values
2289        ///
2290        /// # Parameters
2291        ///
2292        /// * `values` - The list of int16 values to add
2293        ///
2294        /// # Returns
2295        ///
2296        /// If types match, returns `Ok(())`; otherwise returns an error
2297        add_int16s, Int16, i16, DataType::Int16
2298    }
2299
2300    impl_add_multi_values! {
2301        /// Add multiple int32 values
2302        ///
2303        /// # Parameters
2304        ///
2305        /// * `values` - The list of int32 values to add
2306        ///
2307        /// # Returns
2308        ///
2309        /// If types match, returns `Ok(())`; otherwise returns an error
2310        add_int32s, Int32, i32, DataType::Int32
2311    }
2312
2313    impl_add_multi_values! {
2314        /// Add multiple int64 values
2315        ///
2316        /// # Parameters
2317        ///
2318        /// * `values` - The list of int64 values to add
2319        ///
2320        /// # Returns
2321        ///
2322        /// If types match, returns `Ok(())`; otherwise returns an error
2323        add_int64s, Int64, i64, DataType::Int64
2324    }
2325
2326    impl_add_multi_values! {
2327        /// Add multiple int128 values
2328        ///
2329        /// # Parameters
2330        ///
2331        /// * `values` - The list of int128 values to add
2332        ///
2333        /// # Returns
2334        ///
2335        /// If types match, returns `Ok(())`; otherwise returns an error
2336        add_int128s, Int128, i128, DataType::Int128
2337    }
2338
2339    impl_add_multi_values! {
2340        /// Add multiple uint8 values
2341        ///
2342        /// # Parameters
2343        ///
2344        /// * `values` - The list of uint8 values to add
2345        ///
2346        /// # Returns
2347        ///
2348        /// If types match, returns `Ok(())`; otherwise returns an error
2349        add_uint8s, UInt8, u8, DataType::UInt8
2350    }
2351
2352    impl_add_multi_values! {
2353        /// Add multiple uint16 values
2354        ///
2355        /// # Parameters
2356        ///
2357        /// * `values` - The list of uint16 values to add
2358        ///
2359        /// # Returns
2360        ///
2361        /// If types match, returns `Ok(())`; otherwise returns an error
2362        add_uint16s, UInt16, u16, DataType::UInt16
2363    }
2364
2365    impl_add_multi_values! {
2366        /// Add multiple uint32 values
2367        ///
2368        /// # Parameters
2369        ///
2370        /// * `values` - The list of uint32 values to add
2371        ///
2372        /// # Returns
2373        ///
2374        /// If types match, returns `Ok(())`; otherwise returns an error
2375        add_uint32s, UInt32, u32, DataType::UInt32
2376    }
2377
2378    impl_add_multi_values! {
2379        /// Add multiple uint64 values
2380        ///
2381        /// # Parameters
2382        ///
2383        /// * `values` - The list of uint64 values to add
2384        ///
2385        /// # Returns
2386        ///
2387        /// If types match, returns `Ok(())`; otherwise returns an error
2388        add_uint64s, UInt64, u64, DataType::UInt64
2389    }
2390
2391    impl_add_multi_values! {
2392        /// Add multiple uint128 values
2393        ///
2394        /// # Parameters
2395        ///
2396        /// * `values` - The list of uint128 values to add
2397        ///
2398        /// # Returns
2399        ///
2400        /// If types match, returns `Ok(())`; otherwise returns an error
2401        add_uint128s, UInt128, u128, DataType::UInt128
2402    }
2403
2404    impl_add_multi_values! {
2405        /// Add multiple float32 values
2406        ///
2407        /// # Parameters
2408        ///
2409        /// * `values` - The list of float32 values to add
2410        ///
2411        /// # Returns
2412        ///
2413        /// If types match, returns `Ok(())`; otherwise returns an error
2414        add_float32s, Float32, f32, DataType::Float32
2415    }
2416
2417    impl_add_multi_values! {
2418        /// Add multiple float64 values
2419        ///
2420        /// # Parameters
2421        ///
2422        /// * `values` - The list of float64 values to add
2423        ///
2424        /// # Returns
2425        ///
2426        /// If types match, returns `Ok(())`; otherwise returns an error
2427        add_float64s, Float64, f64, DataType::Float64
2428    }
2429
2430    impl_add_multi_values! {
2431        /// Add multiple string values
2432        ///
2433        /// # Parameters
2434        ///
2435        /// * `values` - The list of string values to add
2436        ///
2437        /// # Returns
2438        ///
2439        /// If types match, returns `Ok(())`; otherwise returns an error
2440        ///
2441        /// # Example
2442        ///
2443        /// ```rust
2444        /// use qubit_value::MultiValues;
2445        ///
2446        /// let mut values = MultiValues::String(vec!["hello".to_string()]);
2447        /// values.add_strings(vec!["world".to_string(), "rust".to_string()]).unwrap();
2448        /// assert_eq!(values.get_strings().unwrap(), &["hello", "world", "rust"]);
2449        /// ```
2450        add_strings, String, String, DataType::String
2451    }
2452
2453    impl_add_multi_values! {
2454        /// Add multiple date values
2455        ///
2456        /// # Parameters
2457        ///
2458        /// * `values` - The list of date values to add
2459        ///
2460        /// # Returns
2461        ///
2462        /// If types match, returns `Ok(())`; otherwise returns an error
2463        add_dates, Date, NaiveDate, DataType::Date
2464    }
2465
2466    impl_add_multi_values! {
2467        /// Add multiple time values
2468        ///
2469        /// # Parameters
2470        ///
2471        /// * `values` - The list of time values to add
2472        ///
2473        /// # Returns
2474        ///
2475        /// If types match, returns `Ok(())`; otherwise returns an error
2476        add_times, Time, NaiveTime, DataType::Time
2477    }
2478
2479    impl_add_multi_values! {
2480        /// Add multiple datetime values
2481        ///
2482        /// # Parameters
2483        ///
2484        /// * `values` - The list of datetime values to add
2485        ///
2486        /// # Returns
2487        ///
2488        /// If types match, returns `Ok(())`; otherwise returns an error
2489        add_datetimes, DateTime, NaiveDateTime, DataType::DateTime
2490    }
2491
2492    impl_add_multi_values! {
2493        /// Add multiple UTC instant values
2494        ///
2495        /// # Parameters
2496        ///
2497        /// * `values` - The list of UTC instant values to add
2498        ///
2499        /// # Returns
2500        ///
2501        /// If types match, returns `Ok(())`; otherwise returns an error
2502        add_instants, Instant, DateTime<Utc>, DataType::Instant
2503    }
2504
2505    impl_add_multi_values! {
2506        /// Add multiple big integer values
2507        ///
2508        /// # Parameters
2509        ///
2510        /// * `values` - The list of big integer values to add
2511        ///
2512        /// # Returns
2513        ///
2514        /// If types match, returns `Ok(())`; otherwise returns an error
2515        add_bigintegers, BigInteger, BigInt, DataType::BigInteger
2516    }
2517
2518    impl_add_multi_values! {
2519        /// Add multiple big decimal values
2520        ///
2521        /// # Parameters
2522        ///
2523        /// * `values` - The list of big decimal values to add
2524        ///
2525        /// # Returns
2526        ///
2527        /// If types match, returns `Ok(())`; otherwise returns an error
2528        add_bigdecimals, BigDecimal, BigDecimal, DataType::BigDecimal
2529    }
2530
2531    impl_add_multi_values! {
2532        /// Add multiple isize values
2533        add_intsizes, IntSize, isize, DataType::IntSize
2534    }
2535
2536    impl_add_multi_values! {
2537        /// Add multiple usize values
2538        add_uintsizes, UIntSize, usize, DataType::UIntSize
2539    }
2540
2541    impl_add_multi_values! {
2542        /// Add multiple Duration values
2543        add_durations, Duration, Duration, DataType::Duration
2544    }
2545
2546    impl_add_multi_values! {
2547        /// Add multiple Url values
2548        add_urls, Url, Url, DataType::Url
2549    }
2550
2551    impl_add_multi_values! {
2552        /// Add multiple StringMap values
2553        add_string_maps, StringMap, HashMap<String, String>, DataType::StringMap
2554    }
2555
2556    impl_add_multi_values! {
2557        /// Add multiple Json values
2558        add_jsons, Json, serde_json::Value, DataType::Json
2559    }
2560
2561    // ========================================================================
2562    // Add multiple values via slice operations
2563    // ========================================================================
2564
2565    impl_add_multi_values_slice! {
2566        /// Add multiple boolean values via slice
2567        ///
2568        /// # Parameters
2569        ///
2570        /// * `values` - The boolean value slice to add
2571        ///
2572        /// # Returns
2573        ///
2574        /// If types match, returns `Ok(())`; otherwise returns an error
2575        add_bools_slice, Bool, bool, DataType::Bool
2576    }
2577
2578    impl_add_multi_values_slice! {
2579        /// Add multiple character values via slice
2580        ///
2581        /// # Parameters
2582        ///
2583        /// * `values` - The character value slice to add
2584        ///
2585        /// # Returns
2586        ///
2587        /// If types match, returns `Ok(())`; otherwise returns an error
2588        add_chars_slice, Char, char, DataType::Char
2589    }
2590
2591    impl_add_multi_values_slice! {
2592        /// Add multiple int8 values via slice
2593        ///
2594        /// # Parameters
2595        ///
2596        /// * `values` - The int8 value slice to add
2597        ///
2598        /// # Returns
2599        ///
2600        /// If types match, returns `Ok(())`; otherwise returns an error
2601        add_int8s_slice, Int8, i8, DataType::Int8
2602    }
2603
2604    impl_add_multi_values_slice! {
2605        /// Add multiple int16 values via slice
2606        ///
2607        /// # Parameters
2608        ///
2609        /// * `values` - The int16 value slice to add
2610        ///
2611        /// # Returns
2612        ///
2613        /// If types match, returns `Ok(())`; otherwise returns an error
2614        add_int16s_slice, Int16, i16, DataType::Int16
2615    }
2616
2617    impl_add_multi_values_slice! {
2618        /// Add multiple int32 values via slice
2619        ///
2620        /// # Parameters
2621        ///
2622        /// * `values` - The int32 value slice to add
2623        ///
2624        /// # Returns
2625        ///
2626        /// If types match, returns `Ok(())`; otherwise returns an error
2627        add_int32s_slice, Int32, i32, DataType::Int32
2628    }
2629
2630    impl_add_multi_values_slice! {
2631        /// Add multiple int64 values via slice
2632        ///
2633        /// # Parameters
2634        ///
2635        /// * `values` - The int64 value slice to add
2636        ///
2637        /// # Returns
2638        ///
2639        /// If types match, returns `Ok(())`; otherwise returns an error
2640        add_int64s_slice, Int64, i64, DataType::Int64
2641    }
2642
2643    impl_add_multi_values_slice! {
2644        /// Add multiple int128 values via slice
2645        ///
2646        /// # Parameters
2647        ///
2648        /// * `values` - The int128 value slice to add
2649        ///
2650        /// # Returns
2651        ///
2652        /// If types match, returns `Ok(())`; otherwise returns an error
2653        add_int128s_slice, Int128, i128, DataType::Int128
2654    }
2655
2656    impl_add_multi_values_slice! {
2657        /// Add multiple uint8 values via slice
2658        ///
2659        /// # Parameters
2660        ///
2661        /// * `values` - The uint8 value slice to add
2662        ///
2663        /// # Returns
2664        ///
2665        /// If types match, returns `Ok(())`; otherwise returns an error
2666        add_uint8s_slice, UInt8, u8, DataType::UInt8
2667    }
2668
2669    impl_add_multi_values_slice! {
2670        /// Add multiple uint16 values via slice
2671        ///
2672        /// # Parameters
2673        ///
2674        /// * `values` - The uint16 value slice to add
2675        ///
2676        /// # Returns
2677        ///
2678        /// If types match, returns `Ok(())`; otherwise returns an error
2679        add_uint16s_slice, UInt16, u16, DataType::UInt16
2680    }
2681
2682    impl_add_multi_values_slice! {
2683        /// Add multiple uint32 values via slice
2684        ///
2685        /// # Parameters
2686        ///
2687        /// * `values` - The uint32 value slice to add
2688        ///
2689        /// # Returns
2690        ///
2691        /// If types match, returns `Ok(())`; otherwise returns an error
2692        add_uint32s_slice, UInt32, u32, DataType::UInt32
2693    }
2694
2695    impl_add_multi_values_slice! {
2696        /// Add multiple uint64 values via slice
2697        ///
2698        /// # Parameters
2699        ///
2700        /// * `values` - The uint64 value slice to add
2701        ///
2702        /// # Returns
2703        ///
2704        /// If types match, returns `Ok(())`; otherwise returns an error
2705        add_uint64s_slice, UInt64, u64, DataType::UInt64
2706    }
2707
2708    impl_add_multi_values_slice! {
2709        /// Add multiple uint128 values via slice
2710        ///
2711        /// # Parameters
2712        ///
2713        /// * `values` - The uint128 value slice to add
2714        ///
2715        /// # Returns
2716        ///
2717        /// If types match, returns `Ok(())`; otherwise returns an error
2718        add_uint128s_slice, UInt128, u128, DataType::UInt128
2719    }
2720
2721    impl_add_multi_values_slice! {
2722        /// Add multiple float32 values via slice
2723        ///
2724        /// # Parameters
2725        ///
2726        /// * `values` - The float32 value slice to add
2727        ///
2728        /// # Returns
2729        ///
2730        /// If types match, returns `Ok(())`; otherwise returns an error
2731        add_float32s_slice, Float32, f32, DataType::Float32
2732    }
2733
2734    impl_add_multi_values_slice! {
2735        /// Add multiple float64 values via slice
2736        ///
2737        /// # Parameters
2738        ///
2739        /// * `values` - The float64 value slice to add
2740        ///
2741        /// # Returns
2742        ///
2743        /// If types match, returns `Ok(())`; otherwise returns an error
2744        add_float64s_slice, Float64, f64, DataType::Float64
2745    }
2746
2747    impl_add_multi_values_slice! {
2748        /// Add multiple strings via slice
2749        ///
2750        /// # Parameters
2751        ///
2752        /// * `values` - The string slice to add
2753        ///
2754        /// # Returns
2755        ///
2756        /// If types match, returns `Ok(())`; otherwise returns an error
2757        add_strings_slice, String, String, DataType::String
2758    }
2759
2760    impl_add_multi_values_slice! {
2761        /// Add multiple date values via slice
2762        ///
2763        /// # Parameters
2764        ///
2765        /// * `values` - The date value slice to add
2766        ///
2767        /// # Returns
2768        ///
2769        /// If types match, returns `Ok(())`; otherwise returns an error
2770        add_dates_slice, Date, NaiveDate, DataType::Date
2771    }
2772
2773    impl_add_multi_values_slice! {
2774        /// Add multiple time values via slice
2775        ///
2776        /// # Parameters
2777        ///
2778        /// * `values` - The time value slice to add
2779        ///
2780        /// # Returns
2781        ///
2782        /// If types match, returns `Ok(())`; otherwise returns an error
2783        add_times_slice, Time, NaiveTime, DataType::Time
2784    }
2785
2786    impl_add_multi_values_slice! {
2787        /// Add multiple datetime values via slice
2788        ///
2789        /// # Parameters
2790        ///
2791        /// * `values` - The datetime value slice to add
2792        ///
2793        /// # Returns
2794        ///
2795        /// If types match, returns `Ok(())`; otherwise returns an error
2796        add_datetimes_slice, DateTime, NaiveDateTime, DataType::DateTime
2797    }
2798
2799    impl_add_multi_values_slice! {
2800        /// Add multiple UTC instant values via slice
2801        ///
2802        /// # Parameters
2803        ///
2804        /// * `values` - The UTC instant value slice to add
2805        ///
2806        /// # Returns
2807        ///
2808        /// If types match, returns `Ok(())`; otherwise returns an error
2809        add_instants_slice, Instant, DateTime<Utc>, DataType::Instant
2810    }
2811
2812    impl_add_multi_values_slice! {
2813        /// Add multiple big integer values via slice
2814        ///
2815        /// # Parameters
2816        ///
2817        /// * `values` - The big integer value slice to add
2818        ///
2819        /// # Returns
2820        ///
2821        /// If types match, returns `Ok(())`; otherwise returns an error
2822        add_bigintegers_slice, BigInteger, BigInt, DataType::BigInteger
2823    }
2824
2825    impl_add_multi_values_slice! {
2826        /// Add multiple big decimal values via slice
2827        ///
2828        /// # Parameters
2829        ///
2830        /// * `values` - The big decimal value slice to add
2831        ///
2832        /// # Returns
2833        ///
2834        /// If types match, returns `Ok(())`; otherwise returns an error
2835        add_bigdecimals_slice, BigDecimal, BigDecimal, DataType::BigDecimal
2836    }
2837
2838    impl_add_multi_values_slice! {
2839        /// Add multiple isize values via slice
2840        add_intsizes_slice, IntSize, isize, DataType::IntSize
2841    }
2842
2843    impl_add_multi_values_slice! {
2844        /// Add multiple usize values via slice
2845        add_uintsizes_slice, UIntSize, usize, DataType::UIntSize
2846    }
2847
2848    impl_add_multi_values_slice! {
2849        /// Add multiple Duration values via slice
2850        add_durations_slice, Duration, Duration, DataType::Duration
2851    }
2852
2853    impl_add_multi_values_slice! {
2854        /// Add multiple Url values via slice
2855        add_urls_slice, Url, Url, DataType::Url
2856    }
2857
2858    impl_add_multi_values_slice! {
2859        /// Add multiple StringMap values via slice
2860        add_string_maps_slice, StringMap, HashMap<String, String>, DataType::StringMap
2861    }
2862
2863    impl_add_multi_values_slice! {
2864        /// Add multiple Json values via slice
2865        add_jsons_slice, Json, serde_json::Value, DataType::Json
2866    }
2867}