pub enum Value {
Null,
Bool(bool),
Int(i64),
UInt(u64),
Float(f64),
Decimal(Decimal),
String(String),
Date(NaiveDate),
DateTime(DateTime<FixedOffset>),
Array(Vec<Value>),
Object(IndexMap<String, Value>),
}Expand description
A dynamic report value.
Variants§
Null
JSON null / missing value.
Bool(bool)
Boolean.
Int(i64)
Signed integer.
UInt(u64)
Unsigned integer from Arrow/DB inputs.
Float(f64)
Floating point.
Decimal(Decimal)
Exact decimal.
String(String)
UTF-8 string.
Date(NaiveDate)
Calendar date.
DateTime(DateTime<FixedOffset>)
Timestamp with fixed offset.
Array(Vec<Value>)
Ordered list.
Object(IndexMap<String, Value>)
Insertion-ordered map.
Implementations§
Source§impl Value
impl Value
Sourcepub fn from_object(object: IndexMap<String, Value>) -> Self
pub fn from_object(object: IndexMap<String, Value>) -> Self
Wrap an object map.
Sourcepub fn from_array(array: Vec<Value>) -> Self
pub fn from_array(array: Vec<Value>) -> Self
Wrap a list.
Sourcepub fn is_null(&self) -> bool
pub fn is_null(&self) -> bool
Return true for Value::Null.
Sourcepub fn is_string(&self) -> bool
pub fn is_string(&self) -> bool
Return true for Value::String.
Sourcepub fn is_array(&self) -> bool
pub fn is_array(&self) -> bool
Return true for Value::Array.
Sourcepub fn is_object(&self) -> bool
pub fn is_object(&self) -> bool
Return true for Value::Object.
Sourcepub fn as_bool(&self) -> Option<bool>
pub fn as_bool(&self) -> Option<bool>
Borrow the bool when this is Value::Bool.
Sourcepub fn as_str(&self) -> Option<&str>
pub fn as_str(&self) -> Option<&str>
Borrow the string when this is Value::String.
Sourcepub fn as_array_mut(&mut self) -> Option<&mut Vec<Value>>
pub fn as_array_mut(&mut self) -> Option<&mut Vec<Value>>
Mutably borrow the list when this is Value::Array.
Sourcepub fn as_object(&self) -> Option<&IndexMap<String, Value>>
pub fn as_object(&self) -> Option<&IndexMap<String, Value>>
Borrow the map when this is Value::Object.
Sourcepub fn as_object_mut(&mut self) -> Option<&mut IndexMap<String, Value>>
pub fn as_object_mut(&mut self) -> Option<&mut IndexMap<String, Value>>
Mutably borrow the map when this is Value::Object.
Sourcepub fn contains_key(&self, key: &str) -> bool
pub fn contains_key(&self, key: &str) -> bool
Return true when the object contains key.
Sourcepub fn insert(
&mut self,
key: impl Into<String>,
value: impl Into<Value>,
) -> Option<Value>
pub fn insert( &mut self, key: impl Into<String>, value: impl Into<Value>, ) -> Option<Value>
Insert a key into the object and return the previous value.
Sourcepub fn push(&mut self, value: impl Into<Value>)
pub fn push(&mut self, value: impl Into<Value>)
Append to the list; no-op for non-array values.
Sourcepub fn to_json(&self) -> Value
pub fn to_json(&self) -> Value
Convert to a serde_json::Value (dates/decimals become strings, NaN/inf
become null).
Sourcepub fn from_json(value: Value) -> Self
pub fn from_json(value: Value) -> Self
Convert from a serde_json::Value preserving object order.
Sourcepub fn to_json_string(&self) -> String
pub fn to_json_string(&self) -> String
Serialize with to_json.
Trait Implementations§
Source§impl<'de> Deserialize<'de> for Value
impl<'de> Deserialize<'de> for Value
Source§fn 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>,
Source§impl From<DateTime<FixedOffset>> for Value
impl From<DateTime<FixedOffset>> for Value
Source§fn from(value: DateTime<FixedOffset>) -> Self
fn from(value: DateTime<FixedOffset>) -> Self
impl StructuralPartialEq for Value
Auto Trait Implementations§
impl Forget for Value
impl Freeze for Valuewhere
*const u8 is !null: Freeze,
PhantomData<u8>: Freeze,
NonZero<i32>: Freeze,
FixedOffset: Freeze,
PhantomData<Value>: Freeze,
PhantomData<usize>: Freeze,
PhantomData<Bucket<String, Value>>: Freeze,
impl Move for Value
impl RefUnwindSafe for Value
impl Send for Value
impl Sync for Value
impl Unpin for Value
impl UnsafeUnpin for Valuewhere
*const u8 is !null: UnsafeUnpin,
PhantomData<u8>: UnsafeUnpin,
NonZeroI32Inner: UnsafeUnpin,
FixedOffset: UnsafeUnpin,
PhantomData<Value>: UnsafeUnpin,
PhantomData<usize>: UnsafeUnpin,
PhantomData<Bucket<String, Value>>: UnsafeUnpin,
impl UnwindSafe for Valuewhere
RawVecInner: UnwindSafe,
NonZero<i32>: UnwindSafe,
FixedOffset: UnwindSafe,
NonNull<u8>: UnwindSafe,
Blanket Implementations§
impl<T> Allocation for T
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
impl<T> ErasedDestructor for Twhere
T: 'static,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more