Skip to main content

ConfigValue

Trait ConfigValue 

Source
pub trait ConfigValue: Clone {
    type Object: ConfigObject<Self>;

    // Required methods
    fn kind(&self) -> &'static str;
    fn as_object(&self) -> Option<&Self::Object>;
    fn as_object_mut(&mut self) -> Option<&mut Self::Object>;
    fn into_object(self) -> Result<Self::Object, Self>;
    fn as_array(&self) -> Option<&[Self]>;
    fn as_str(&self) -> Option<&str>;
    fn object(object: Self::Object) -> Self;
    fn array(items: Vec<Self>) -> Self;
    fn string(text: String) -> Self;
    fn stringify(&self) -> Option<String>;
}
Expand description

Structural operations on a native configuration value.

Scalars stay opaque to merge and traversal. Implementations classify integers and floats as number, and render scalars without quoting strings.

Required Associated Types§

Source

type Object: ConfigObject<Self>

The native object type.

Required Methods§

Source

fn kind(&self) -> &'static str

A diagnostic kind: object, array, string, number, bool, null or datetime.

Source

fn as_object(&self) -> Option<&Self::Object>

Borrow an object, if this is one.

Source

fn as_object_mut(&mut self) -> Option<&mut Self::Object>

Mutably borrow an object, if this is one.

Source

fn into_object(self) -> Result<Self::Object, Self>

Consume an object; return the original value for any other kind.

Source

fn as_array(&self) -> Option<&[Self]>

Borrow an array, if this is one.

Source

fn as_str(&self) -> Option<&str>

Borrow a string, if this is one.

Source

fn object(object: Self::Object) -> Self

Wrap a native object.

Source

fn array(items: Vec<Self>) -> Self

Construct an array.

Source

fn string(text: String) -> Self

Construct a string.

Source

fn stringify(&self) -> Option<String>

Render a scalar for an embedded reference. Containers and null reject. Finite floats keep Rust float spelling; serializers may use another spelling.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementations on Foreign Types§

Source§

impl ConfigValue for Value

Source§

type Object = Map<String, Value>

Source§

fn kind(&self) -> &'static str

Source§

fn as_object(&self) -> Option<&<Self as ConfigValue>::Object>

Source§

fn as_object_mut(&mut self) -> Option<&mut <Self as ConfigValue>::Object>

Source§

fn into_object(self) -> Result<<Self as ConfigValue>::Object, Self>

Source§

fn as_array(&self) -> Option<&[Self]>

Source§

fn as_str(&self) -> Option<&str>

Source§

fn object(object: <Self as ConfigValue>::Object) -> Self

Source§

fn array(items: Vec<Self>) -> Self

Source§

fn string(text: String) -> Self

Source§

fn stringify(&self) -> Option<String>

Source§

impl ConfigValue for Value

Source§

type Object = Map<String, Value>

Source§

fn kind(&self) -> &'static str

Source§

fn as_object(&self) -> Option<&Self::Object>

Source§

fn as_object_mut(&mut self) -> Option<&mut Self::Object>

Source§

fn into_object(self) -> Result<Self::Object, Self>

Source§

fn as_array(&self) -> Option<&[Self]>

Source§

fn as_str(&self) -> Option<&str>

Source§

fn object(object: Self::Object) -> Self

Source§

fn array(items: Vec<Self>) -> Self

Source§

fn string(text: String) -> Self

Source§

fn stringify(&self) -> Option<String>

Implementors§