Module std::encoding::wire::value_trait

Canonical opaque Value contract shared by the stdlib encoding modules.

The handle stays opaque by design: #1247 settled that callers should not depend on any encoding's internal representation, only on a stable method surface and the shared 0..6 type-tag prefix.

Shared tags:

Encoding-specific variants, if any, start at 7+.

Note: TOML has no null type, so hew_toml_type never returns 0. The 0 slot is reserved in the shared prefix so that cross-encoding consumers can use a uniform 0..6 tag range. Downstream TOML consumers should not add a 0 => arm expecting a real null โ€” it will never fire.

Contents

Traits

Trait CanonicalValueMethods

Common Value methods implemented by stdlib encodings with opaque handles.

Methods

fn stringify(self: Self) -> string

Serialize the value back to its source encoding.

fn type_of(self: Self) -> i32

Return the canonical shared type tag.

fn get_bool(self: Self) -> i32

Extract the boolean value (0 or 1).

fn get_int(self: Self) -> i64

Extract the integer value.

fn get_float(self: Self) -> f64

Extract the floating-point value.

fn get_string(self: Self) -> string

Extract the string value.

fn get_field(self: Self, key: string) -> Self

Look up a field by key in an object-like value.

fn array_len(self: Self) -> i64

Return the number of elements in an array-like value.

fn array_get(self: Self, index: i64) -> Self

Return the element at the given index in an array-like value.

fn free(self: Self)

Release the value resources.

fn with_string(self: Self, key: string, val: string) -> Self

Set a string field on an object-like value. Returns the object for chaining.

fn with_int(self: Self, key: string, val: i64) -> Self

Set an integer field. Returns the object for chaining.

fn with_float(self: Self, key: string, val: f64) -> Self

Set a float field. Returns the object for chaining.

fn with_bool(self: Self, key: string, val: bool) -> Self

Set a boolean field. Returns the object for chaining.

fn with(self: Self, key: string, child: Self) -> Self

Set a child value on an object-like value. The child is consumed.

fn push(self: Self, child: Self) -> Self

Push a child value onto an array-like value. The child is consumed.

fn push_int(self: Self, val: i64) -> Self

Push an integer onto an array-like value.

fn push_string(self: Self, val: string) -> Self

Push a string onto an array-like value.

fn push_float(self: Self, val: f64) -> Self

Push a float onto an array-like value.

fn push_bool(self: Self, val: bool) -> Self

Push a boolean onto an array-like value.