Skip to main content

qubit_value/multi_values/
multi_values_accessors.rs

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