pub enum DataValue {
    Int(SbrdInt),
    Real(SbrdReal),
    Bool(SbrdBool),
    String(String),
    Null,
}
Expand description

Value for Schema

Variants

Int(SbrdInt)

Integer

Real(SbrdReal)

Real

Bool(SbrdBool)

Boolean

String(String)

String

Null

Null

Implementations

Convert to String to use when permute with other Strings

Convert to String to use parse

Format this value

Support Rust-format syntax. But not support position, variable, padding with character and Pointer format ({:p}). Debug format is not supported in release build.

Examples
fn main(){
    use sbrd_gen::value::DataValue;

    assert_eq!(Some("ignore value".to_string()), DataValue::Int(12).format("ignore value"));
    assert_eq!(Some("12".to_string()), DataValue::Int(12).format("{}"));
    assert_eq!(Some("{}".to_string()), DataValue::Int(12).format("{{}}"));
    assert_eq!(Some("Rate= +12.35".to_string()), DataValue::Real(12.345).format("Rate={:+7.2}"));
    assert_eq!(Some("Rate=+012.35".to_string()), DataValue::Real(12.345).format("Rate={:+07.2}"));
    assert_eq!(Some(" aiueoあいうえお ".to_string()), DataValue::String("aiueoあいうえお".to_string()).format("{:^12}"));
    assert_eq!(Some("true    ".to_string()), DataValue::Bool(true).format("{:<8}"));
    assert_eq!(Some("null".to_string()), DataValue::Null.format("{:<10}"));
}

Trait Implementations

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Formats the value using the given formatter. Read more

Deserialize this value from the given Serde deserializer. Read more

Formats the value using the given formatter. Read more

Returns true if self can be formatted using the given specifier.

Formats the value the way it would be formatted if it implemented std::fmt::Display.

Formats the value the way it would be formatted if it implemented std::fmt::Debug.

Formats the value the way it would be formatted if it implemented std::fmt::Octal.

Formats the value the way it would be formatted if it implemented std::fmt::LowerHex.

Formats the value the way it would be formatted if it implemented std::fmt::UpperHex.

Formats the value the way it would be formatted if it implemented std::fmt::Binary.

Formats the value the way it would be formatted if it implemented std::fmt::LowerExp.

Formats the value the way it would be formatted if it implemented std::fmt::UpperExp.

Performs a type conversion into usize that might fail. Like TryInto<usize>, but does not consume self. The parser uses this to support formats whose width or precision use “dollar syntax”. For more information about these, see std::fmt. The default implementation always returns an error. Read more

Returns true if self can be formatted using the given specifier.

Formats the value the way it would be formatted if it implemented std::fmt::Display.

Formats the value the way it would be formatted if it implemented std::fmt::Debug.

Formats the value the way it would be formatted if it implemented std::fmt::Octal.

Formats the value the way it would be formatted if it implemented std::fmt::LowerHex.

Formats the value the way it would be formatted if it implemented std::fmt::UpperHex.

Formats the value the way it would be formatted if it implemented std::fmt::Binary.

Formats the value the way it would be formatted if it implemented std::fmt::LowerExp.

Formats the value the way it would be formatted if it implemented std::fmt::UpperExp.

Performs a type conversion into usize that might fail. Like TryInto<usize>, but does not consume self. The parser uses this to support formats whose width or precision use “dollar syntax”. For more information about these, see std::fmt. The default implementation always returns an error. Read more

Converts to this type from the input type.

Converts to this type from the input type.

Converts to this type from the input type.

Converts to this type from the input type.

Converts to this type from the input type.

Converts to this type from the input type.

Converts to this type from the input type.

This method tests for self and other values to be equal, and is used by ==. Read more

This method tests for !=.

Serialize this value into the given Serde serializer. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

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

The resulting type after obtaining ownership.

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

🔬 This is a nightly-only experimental API. (toowned_clone_into)

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

Converts the given value to a String. Read more

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.