pub enum NativeValue {
Null,
Bool(bool),
Integer(i64),
Float(f64),
String(String),
Datetime(String),
Array(Vec<NativeValue>),
Object(NativeMap),
}Expand description
A format-neutral value read from or written to a native file.
Objects keep their key order (see NativeMap); equality ignores it,
because neither JSON nor TOML gives key order a meaning.
Variants§
Null
JSON null. TOML has none, so writing it to TOML is invalid_value.
Bool(bool)
Integer(i64)
Float(f64)
A finite float. JSON numbers with a fraction or exponent, or outside
the i64 range, read as floats.
String(String)
Datetime(String)
A TOML date-time, in its TOML text form. JSON writes it as a string.
Array(Vec<NativeValue>)
Object(NativeMap)
Implementations§
Source§impl NativeValue
impl NativeValue
Sourcepub fn parse_json(text: &str) -> Result<Self, CoreError>
pub fn parse_json(text: &str) -> Result<Self, CoreError>
Parses JSON or JSONC text (one value). Duplicate keys: the first
wins, as in every Document operation.
pub fn as_str(&self) -> Option<&str>
pub fn as_object(&self) -> Option<&NativeMap>
pub fn as_array(&self) -> Option<&[NativeValue]>
Trait Implementations§
Source§impl Clone for NativeValue
impl Clone for NativeValue
Source§impl Debug for NativeValue
impl Debug for NativeValue
Source§impl From<&str> for NativeValue
impl From<&str> for NativeValue
Source§impl From<NativeMap> for NativeValue
impl From<NativeMap> for NativeValue
Source§impl From<String> for NativeValue
impl From<String> for NativeValue
Source§impl From<bool> for NativeValue
impl From<bool> for NativeValue
Source§impl From<i64> for NativeValue
impl From<i64> for NativeValue
Source§impl PartialEq for NativeValue
impl PartialEq for NativeValue
impl StructuralPartialEq for NativeValue
Auto Trait Implementations§
impl Forget for NativeValue
impl Freeze for NativeValuewhere
*const u8 is !null: Freeze,
PhantomData<u8>: Freeze,
PhantomData<NativeValue>: Freeze,
PhantomData<(String, NativeValue)>: Freeze,
impl Move for NativeValue
impl RefUnwindSafe for NativeValue
impl Send for NativeValuewhere
RawVecInner: Send,
impl Sync for NativeValuewhere
RawVecInner: Sync,
impl Unpin for NativeValue
impl UnsafeUnpin for NativeValuewhere
*const u8 is !null: UnsafeUnpin,
PhantomData<u8>: UnsafeUnpin,
PhantomData<NativeValue>: UnsafeUnpin,
PhantomData<(String, NativeValue)>: UnsafeUnpin,
impl UnwindSafe for NativeValuewhere
RawVecInner: UnwindSafe,
Blanket Implementations§
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
Mutably borrows from an owned value. Read more