Expand description
Value for Schema
Variants
Int(SbrdInt)
Integer
Real(SbrdReal)
Real
Bool(SbrdBool)
Boolean
String(String)
String
Null
Null
Implementations
sourceimpl DataValue
impl DataValue
sourcepub fn to_permutation_string(&self) -> String
pub fn to_permutation_string(&self) -> String
Convert to String to use when permute with other Strings
sourcepub fn to_parse_string(&self) -> String
pub fn to_parse_string(&self) -> String
Convert to String to use parse
sourcepub fn format(&self, format: &str) -> Option<String>
pub fn format(&self, format: &str) -> Option<String>
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
sourceimpl<'de> Deserialize<'de> for DataValue
impl<'de> Deserialize<'de> for DataValue
sourcefn 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>,
Deserialize this value from the given Serde deserializer. Read more
sourceimpl FormatArgument for DataValue
impl FormatArgument for DataValue
sourcefn supports_format(&self, specifier: &Specifier) -> bool
fn supports_format(&self, specifier: &Specifier) -> bool
Returns true
if self
can be formatted using the given specifier.
sourcefn fmt_display(&self, f: &mut Formatter<'_>) -> Result
fn fmt_display(&self, f: &mut Formatter<'_>) -> Result
Formats the value the way it would be formatted if it implemented std::fmt::Display
.
sourcefn fmt_debug(&self, f: &mut Formatter<'_>) -> Result
fn fmt_debug(&self, f: &mut Formatter<'_>) -> Result
Formats the value the way it would be formatted if it implemented std::fmt::Debug
.
sourcefn fmt_octal(&self, f: &mut Formatter<'_>) -> Result
fn fmt_octal(&self, f: &mut Formatter<'_>) -> Result
Formats the value the way it would be formatted if it implemented std::fmt::Octal
.
sourcefn fmt_lower_hex(&self, f: &mut Formatter<'_>) -> Result
fn fmt_lower_hex(&self, f: &mut Formatter<'_>) -> Result
Formats the value the way it would be formatted if it implemented std::fmt::LowerHex
.
sourcefn fmt_upper_hex(&self, f: &mut Formatter<'_>) -> Result
fn fmt_upper_hex(&self, f: &mut Formatter<'_>) -> Result
Formats the value the way it would be formatted if it implemented std::fmt::UpperHex
.
sourcefn fmt_binary(&self, f: &mut Formatter<'_>) -> Result
fn fmt_binary(&self, f: &mut Formatter<'_>) -> Result
Formats the value the way it would be formatted if it implemented std::fmt::Binary
.
sourcefn fmt_lower_exp(&self, f: &mut Formatter<'_>) -> Result
fn fmt_lower_exp(&self, f: &mut Formatter<'_>) -> Result
Formats the value the way it would be formatted if it implemented std::fmt::LowerExp
.
sourcefn fmt_upper_exp(&self, f: &mut Formatter<'_>) -> Result
fn fmt_upper_exp(&self, f: &mut Formatter<'_>) -> Result
Formats the value the way it would be formatted if it implemented std::fmt::UpperExp
.
sourceimpl<'a> FormatArgument for &'a DataValue
impl<'a> FormatArgument for &'a DataValue
sourcefn supports_format(&self, specifier: &Specifier) -> bool
fn supports_format(&self, specifier: &Specifier) -> bool
Returns true
if self
can be formatted using the given specifier.
sourcefn fmt_display(&self, f: &mut Formatter<'_>) -> Result
fn fmt_display(&self, f: &mut Formatter<'_>) -> Result
Formats the value the way it would be formatted if it implemented std::fmt::Display
.
sourcefn fmt_debug(&self, f: &mut Formatter<'_>) -> Result
fn fmt_debug(&self, f: &mut Formatter<'_>) -> Result
Formats the value the way it would be formatted if it implemented std::fmt::Debug
.
sourcefn fmt_octal(&self, f: &mut Formatter<'_>) -> Result
fn fmt_octal(&self, f: &mut Formatter<'_>) -> Result
Formats the value the way it would be formatted if it implemented std::fmt::Octal
.
sourcefn fmt_lower_hex(&self, f: &mut Formatter<'_>) -> Result
fn fmt_lower_hex(&self, f: &mut Formatter<'_>) -> Result
Formats the value the way it would be formatted if it implemented std::fmt::LowerHex
.
sourcefn fmt_upper_hex(&self, f: &mut Formatter<'_>) -> Result
fn fmt_upper_hex(&self, f: &mut Formatter<'_>) -> Result
Formats the value the way it would be formatted if it implemented std::fmt::UpperHex
.
sourcefn fmt_binary(&self, f: &mut Formatter<'_>) -> Result
fn fmt_binary(&self, f: &mut Formatter<'_>) -> Result
Formats the value the way it would be formatted if it implemented std::fmt::Binary
.
sourcefn fmt_lower_exp(&self, f: &mut Formatter<'_>) -> Result
fn fmt_lower_exp(&self, f: &mut Formatter<'_>) -> Result
Formats the value the way it would be formatted if it implemented std::fmt::LowerExp
.
sourcefn fmt_upper_exp(&self, f: &mut Formatter<'_>) -> Result
fn fmt_upper_exp(&self, f: &mut Formatter<'_>) -> Result
Formats the value the way it would be formatted if it implemented std::fmt::UpperExp
.
sourceimpl From<NaiveDateTime> for DataValue
impl From<NaiveDateTime> for DataValue
sourcefn from(v: SbrdDateTime) -> Self
fn from(v: SbrdDateTime) -> Self
Converts to this type from the input type.
impl StructuralPartialEq for DataValue
Auto Trait Implementations
impl RefUnwindSafe for DataValue
impl Send for DataValue
impl Sync for DataValue
impl Unpin for DataValue
impl UnwindSafe for DataValue
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<T> ToOwned for T where
T: Clone,
impl<T> ToOwned for T where
T: Clone,
type Owned = T
type Owned = T
The resulting type after obtaining ownership.
sourcefn clone_into(&self, target: &mut T)
fn clone_into(&self, target: &mut T)
toowned_clone_into
)Uses borrowed data to replace owned data, usually by cloning. Read more