Skip to main content

NamedMultiValues

Struct NamedMultiValues 

Source
pub struct NamedMultiValues { /* private fields */ }
Expand description

Named multiple values

A container that associates a readable name with a set of MultiValues, suitable for organizing data in key-value (name-multiple values) scenarios, such as configuration items, command-line parameter aggregation, structured log fields, etc.

§Features

  • Provides clear name identification for multiple value collections
  • Exposes the inner MultiValues through explicit accessors
  • Supports serde serialization and deserialization

§Use Cases

  • Aggregating a set of ports, hostnames, etc., as semantically meaningful fields
  • Outputting named multiple value lists in configurations/logs

§Examples

use qubit_value::{NamedMultiValues, MultiValues};

// Identify a group of ports with the name "ports"
let named = NamedMultiValues::new(
    "ports",
    MultiValues::Int32(vec![8080, 8081, 8082])
);

assert_eq!(named.name(), "ports");
assert_eq!(named.values().len(), 3);

The wrapper intentionally does not forward MultiValues methods implicitly:

use qubit_value::{MultiValues, NamedMultiValues};

let named = NamedMultiValues::new("ports", MultiValues::Int32(vec![8080]));
let _ = named.len();

Implementations§

Source§

impl NamedMultiValues

Source

pub fn new(name: impl Into<String>, value: MultiValues) -> Self

Create a new named multiple values

Associates a given name with MultiValues, generating a container that can be referenced by name.

§Use Cases
  • Building configuration fields (e.g., servers, ports, etc.)
  • Binding parsed multiple value results to semantic names
§Parameters
  • name - Name of the multiple values
  • value - Content of the multiple values
§Returns

Returns a newly created named multiple values

§Examples
use qubit_value::{NamedMultiValues, MultiValues};

let named = NamedMultiValues::new(
    "servers",
    MultiValues::String(vec!["s1".to_string(), "s2".to_string()])
);
assert_eq!(named.name(), "servers");
Source

pub fn decode_json_slice(input: &[u8]) -> Result<Self, ValueWireDecodeError>

Decodes a complete named collection JSON document with default limits.

§Parameters
  • input - Complete UTF-8 JSON document to decode.
§Returns

The decoded named collection.

§Errors

Returns a JSON, wire-contract, or resource-limit error.

Source

pub fn decode_json_slice_with_limits( input: &[u8], limits: WireLimits, ) -> Result<Self, ValueWireDecodeError>

Decodes a complete named collection JSON document with explicit limits.

The wrapper name and nested collection share one accounting session.

§Parameters
  • input - Complete UTF-8 JSON document to decode.
  • limits - Input and decoded-resource limits.
§Returns

The decoded named collection.

§Errors

Returns a JSON, wire-contract, or resource-limit error.

Source

pub fn name(&self) -> &str

Get a reference to the name

§Returns

Returns a string slice of the name

§Examples
use qubit_value::{NamedMultiValues, MultiValues};

let named = NamedMultiValues::new("items", MultiValues::Int32(vec![1, 2, 3]));
assert_eq!(named.name(), "items");
Source

pub fn set_name(&mut self, name: impl Into<String>)

Set a new name

§Parameters
  • name - The new name
§Returns

No return value

§Examples
use qubit_value::{NamedMultiValues, MultiValues};

let mut named = NamedMultiValues::new("old", MultiValues::Bool(vec![true]));
named.set_name("new");
assert_eq!(named.name(), "new");
Source

pub fn values(&self) -> &MultiValues

Borrows the contained values.

§Returns

A shared reference to the contained MultiValues.

Source

pub fn values_mut(&mut self) -> &mut MultiValues

Mutably borrows the contained values.

§Returns

An exclusive reference to the contained MultiValues.

Source

pub fn set_values(&mut self, values: MultiValues)

Replaces the contained values.

§Parameters
  • values - New collection to store under the existing name.
Source

pub fn into_parts(self) -> (String, MultiValues)

Consumes this wrapper and returns its owned name and values.

§Returns

The (name, values) pair without cloning either component.

Source

pub fn first_named_value(&self) -> NamedValue

Convert this named multi-values into a named single value.

The returned value keeps the same name and uses the first element from the inner MultiValues. If there is no element, the returned value is Value::Unset with the same data type.

§Returns

A named clone of the first item, or a named typed unset value.

Source

pub fn into_first_named_value(self) -> NamedValue

Consumes this container and converts its first item to a named value.

The owned name and first stored item are moved into the result. An empty or unset collection produces crate::Value::Unset with the same data type.

§Returns

A named owned first item, or a named typed unset value.

Trait Implementations§

Source§

impl Clone for NamedMultiValues

Source§

fn clone(&self) -> NamedMultiValues

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for NamedMultiValues

Source§

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

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

impl<'de> Deserialize<'de> for NamedMultiValues

Source§

fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
where D: Deserializer<'de>,

Deserializes a named collection from the V1 wire contract.

Source§

impl Eq for NamedMultiValues

Source§

impl From<NamedValue> for NamedMultiValues

Source§

fn from(named: NamedValue) -> Self

Construct NamedMultiValues from NamedValue

Reuses the name and promotes the single value to a MultiValues containing only one element.

Source§

impl Hash for NamedMultiValues

Source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl PartialEq for NamedMultiValues

Source§

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

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

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

Inequality operator !=. Read more
Source§

impl Redact for NamedMultiValues

Source§

fn redacted(&self) -> Redacted<'_, Self>
where Self: Sized,

Creates a borrowed view using a snapshot of the current default policy. Read more
Source§

fn redacted_with(&self, policy: &RedactionPolicy) -> Redacted<'_, Self>
where Self: Sized,

Creates a borrowed view using a snapshot of policy. Read more
Source§

impl Serialize for NamedMultiValues

Source§

fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
where S: Serializer,

Serializes the name and its explicitly versioned collection.

Source§

impl StructuralPartialEq for NamedMultiValues

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

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

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoValueDefault<T> for T

Source§

fn into_value_default(self) -> T

Converts this argument into the default value. Read more
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.