pub struct NamedValue { /* private fields */ }Expand description
Named single value
Associates a human-readable name with a single Value, facilitating
identification, retrieval, and display in configurations, parameter passing,
and complex data structures.
§Features
- Provides stable name identification for values
- Exposes the inner
Valuethrough explicit accessors - Supports
serdeserialization and deserialization
§Use Cases
- Configuration item encapsulation (e.g.,
"port","timeout", etc.) - Named output of key values in logs/monitoring
- Quick location by name in collections
§Examples
use qubit_value::{NamedValue, Value};
let named = NamedValue::new("flag", Value::Bool(true));
assert!(named.value().get_bool().unwrap());The wrapper intentionally does not forward Value methods implicitly:
use qubit_value::{NamedValue, Value};
let named = NamedValue::new("flag", Value::Bool(true));
let _ = named.get_bool();Implementations§
Source§impl NamedValue
impl NamedValue
Sourcepub fn new(name: impl Into<String>, value: Value) -> Self
pub fn new(name: impl Into<String>, value: Value) -> Self
Create a new named value
Creates a binding instance between a name and a value.
§Parameters
name- Name of the valuevalue- Content of the value
§Returns
Returns a newly created NamedValue instance
§Examples
use qubit_value::{NamedValue, Value};
let named = NamedValue::new("timeout", Value::Int32(30));
assert_eq!(named.name(), "timeout");Sourcepub fn decode_json_slice(input: &[u8]) -> Result<Self, ValueWireDecodeError>
pub fn decode_json_slice(input: &[u8]) -> Result<Self, ValueWireDecodeError>
Sourcepub fn decode_json_slice_with_limits(
input: &[u8],
limits: WireLimits,
) -> Result<Self, ValueWireDecodeError>
pub fn decode_json_slice_with_limits( input: &[u8], limits: WireLimits, ) -> Result<Self, ValueWireDecodeError>
Decodes a complete named scalar JSON document with explicit limits.
The wrapper name and nested scalar share one accounting session.
§Parameters
input- Complete UTF-8 JSON document to decode.limits- Input and decoded-resource limits.
§Returns
The decoded named scalar.
§Errors
Returns a JSON, wire-contract, or resource-limit error.
Sourcepub fn into_parts(self) -> (String, Value)
pub fn into_parts(self) -> (String, Value)
Consumes this wrapper and returns its owned name and value.
§Returns
The (name, value) pair without cloning either component.
Trait Implementations§
Source§impl Clone for NamedValue
impl Clone for NamedValue
Source§fn clone(&self) -> NamedValue
fn clone(&self) -> NamedValue
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for NamedValue
impl Debug for NamedValue
Source§impl<'de> Deserialize<'de> for NamedValue
impl<'de> Deserialize<'de> for NamedValue
Source§fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>where
D: Deserializer<'de>,
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>where
D: Deserializer<'de>,
Deserializes a named scalar value from the V1 wire contract.
impl Eq for NamedValue
Source§impl From<NamedValue> for NamedMultiValues
impl From<NamedValue> for NamedMultiValues
Source§fn from(named: NamedValue) -> Self
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 NamedValue
impl Hash for NamedValue
Source§impl PartialEq for NamedValue
impl PartialEq for NamedValue
Source§impl Redact for NamedValue
impl Redact for NamedValue
Source§fn redacted(&self) -> Redacted<'_, Self>where
Self: Sized,
fn redacted(&self) -> Redacted<'_, Self>where
Self: Sized,
Source§fn redacted_with(&self, policy: &RedactionPolicy) -> Redacted<'_, Self>where
Self: Sized,
fn redacted_with(&self, policy: &RedactionPolicy) -> Redacted<'_, Self>where
Self: Sized,
policy. Read more