Trait nu_protocol::IntoValue

source ·
pub trait IntoValue: Sized {
    // Required method
    fn into_value(self, span: Span) -> Value;
}
Expand description

A trait for converting a value into a Value.

This conversion is infallible, for fallible conversions use TryIntoValue.

§Derivable

This trait can be used with #[derive]. When derived on structs with named fields, the resulting value representation will use Value::Record, where each field of the record corresponds to a field of the struct. For structs with unnamed fields, the value representation will be Value::List, with all fields inserted into a list. Unit structs will be represented as Value::Nothing since they contain no data.

Only enums with no fields may derive this trait. The resulting value representation will be the name of the variant as a Value::String. By default, variant names will be converted to “snake_case”. You can customize the case conversion using #[nu_value(rename_all = "kebab-case")] on the enum. All deterministic and useful case conversions provided by convert_case::Case are supported by specifying the case name followed by “case”. Also all values for #[serde(rename_all = "...")] are valid here.

#[derive(IntoValue)]
#[nu_value(rename_all = "COBOL-CASE")]
enum Bird {
    MountainEagle,
    ForestOwl,
    RiverDuck,
}

assert_eq!(
    Bird::RiverDuck.into_value(Span::unknown()),
    Value::test_string("RIVER-DUCK")
);

Required Methods§

source

fn into_value(self, span: Span) -> Value

Converts the given value to a Value.

Object Safety§

This trait is not object safe.

Implementations on Foreign Types§

source§

impl IntoValue for bool

source§

fn into_value(self, span: Span) -> Value

source§

impl IntoValue for char

source§

fn into_value(self, span: Span) -> Value

source§

impl IntoValue for f32

source§

fn into_value(self, span: Span) -> Value

source§

impl IntoValue for f64

source§

fn into_value(self, span: Span) -> Value

source§

impl IntoValue for i8

source§

fn into_value(self, span: Span) -> Value

source§

impl IntoValue for i16

source§

fn into_value(self, span: Span) -> Value

source§

impl IntoValue for i32

source§

fn into_value(self, span: Span) -> Value

source§

impl IntoValue for i64

source§

fn into_value(self, span: Span) -> Value

source§

impl IntoValue for isize

source§

fn into_value(self, span: Span) -> Value

source§

impl IntoValue for u8

source§

fn into_value(self, span: Span) -> Value

source§

impl IntoValue for u16

source§

fn into_value(self, span: Span) -> Value

source§

impl IntoValue for u32

source§

fn into_value(self, span: Span) -> Value

source§

impl IntoValue for ()

source§

fn into_value(self, span: Span) -> Value

source§

impl IntoValue for String

source§

fn into_value(self, span: Span) -> Value

source§

impl<T0> IntoValue for (T0,)
where T0: IntoValue,

source§

fn into_value(self, span: Span) -> Value

source§

impl<T0, T1> IntoValue for (T0, T1)
where T0: IntoValue, T1: IntoValue,

source§

fn into_value(self, span: Span) -> Value

source§

impl<T0, T1, T2> IntoValue for (T0, T1, T2)
where T0: IntoValue, T1: IntoValue, T2: IntoValue,

source§

fn into_value(self, span: Span) -> Value

source§

impl<T0, T1, T2, T3> IntoValue for (T0, T1, T2, T3)
where T0: IntoValue, T1: IntoValue, T2: IntoValue, T3: IntoValue,

source§

fn into_value(self, span: Span) -> Value

source§

impl<T0, T1, T2, T3, T4> IntoValue for (T0, T1, T2, T3, T4)
where T0: IntoValue, T1: IntoValue, T2: IntoValue, T3: IntoValue, T4: IntoValue,

source§

fn into_value(self, span: Span) -> Value

source§

impl<T0, T1, T2, T3, T4, T5> IntoValue for (T0, T1, T2, T3, T4, T5)
where T0: IntoValue, T1: IntoValue, T2: IntoValue, T3: IntoValue, T4: IntoValue, T5: IntoValue,

source§

fn into_value(self, span: Span) -> Value

source§

impl<T0, T1, T2, T3, T4, T5, T6> IntoValue for (T0, T1, T2, T3, T4, T5, T6)
where T0: IntoValue, T1: IntoValue, T2: IntoValue, T3: IntoValue, T4: IntoValue, T5: IntoValue, T6: IntoValue,

source§

fn into_value(self, span: Span) -> Value

source§

impl<T0, T1, T2, T3, T4, T5, T6, T7> IntoValue for (T0, T1, T2, T3, T4, T5, T6, T7)
where T0: IntoValue, T1: IntoValue, T2: IntoValue, T3: IntoValue, T4: IntoValue, T5: IntoValue, T6: IntoValue, T7: IntoValue,

source§

fn into_value(self, span: Span) -> Value

source§

impl<T0, T1, T2, T3, T4, T5, T6, T7, T8> IntoValue for (T0, T1, T2, T3, T4, T5, T6, T7, T8)
where T0: IntoValue, T1: IntoValue, T2: IntoValue, T3: IntoValue, T4: IntoValue, T5: IntoValue, T6: IntoValue, T7: IntoValue, T8: IntoValue,

source§

fn into_value(self, span: Span) -> Value

source§

impl<T0, T1, T2, T3, T4, T5, T6, T7, T8, T9> IntoValue for (T0, T1, T2, T3, T4, T5, T6, T7, T8, T9)
where T0: IntoValue, T1: IntoValue, T2: IntoValue, T3: IntoValue, T4: IntoValue, T5: IntoValue, T6: IntoValue, T7: IntoValue, T8: IntoValue, T9: IntoValue,

source§

fn into_value(self, span: Span) -> Value

source§

impl<T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10> IntoValue for (T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10)
where T0: IntoValue, T1: IntoValue, T2: IntoValue, T3: IntoValue, T4: IntoValue, T5: IntoValue, T6: IntoValue, T7: IntoValue, T8: IntoValue, T9: IntoValue, T10: IntoValue,

source§

fn into_value(self, span: Span) -> Value

source§

impl<T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11> IntoValue for (T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11)
where T0: IntoValue, T1: IntoValue, T2: IntoValue, T3: IntoValue, T4: IntoValue, T5: IntoValue, T6: IntoValue, T7: IntoValue, T8: IntoValue, T9: IntoValue, T10: IntoValue, T11: IntoValue,

source§

fn into_value(self, span: Span) -> Value

source§

impl<T> IntoValue for Option<T>
where T: IntoValue,

source§

fn into_value(self, span: Span) -> Value

source§

impl<T> IntoValue for Vec<T>
where T: IntoValue,

source§

fn into_value(self, span: Span) -> Value

source§

impl<T, const N: usize> IntoValue for [T; N]
where T: IntoValue,

source§

fn into_value(self, span: Span) -> Value

source§

impl<V> IntoValue for HashMap<String, V>
where V: IntoValue,

source§

fn into_value(self, span: Span) -> Value

Implementors§