Struct jsonnet::JsonValue [−][src]
Rust wrapper for owned libjsonnet JSON values.
These are used as return values from jsonnet native callbacks.
See JsonVal
for the borrowed version.
Implementations
impl<'a> JsonValue<'a>
[src]
pub unsafe fn from_ptr(vm: &'a JsonnetVm, p: *mut JsonnetJsonValue) -> Self
[src]
Construct a JsonValue
from a pointer returned from a
low-level jsonnet C function.
Safety
It is up to the caller to ensure that p
was indeed allocated
by vm
.
pub fn as_ptr(&self) -> *const JsonnetJsonValue
[src]
Returns the inner pointer to this jsonnet value.
The returned pointer will be valid for as long as self
is.
pub fn as_str(&self) -> Option<&str>
[src]
Returns the value, if it is a string.
pub fn as_num(&self) -> Option<f64>
[src]
Returns the value, if it is a number.
pub fn as_bool(&self) -> Option<bool>
[src]
Returns the value, if it is a bool.
pub fn as_null(&self) -> Option<()>
[src]
Returns Some(())
if the value is null
.
pub fn from_str(vm: &'a JsonnetVm, v: &str) -> Self
[src]
Convert the given UTF8 string to a JsonValue.
Panics
Panics if v
contains an embedded nul character.
pub fn from_num(vm: &'a JsonnetVm, v: f64) -> Self
[src]
Convert the given double to a JsonValue.
pub fn from_bool(vm: &'a JsonnetVm, v: bool) -> Self
[src]
Convert the given bool to a JsonValue.
pub fn null(vm: &'a JsonnetVm) -> Self
[src]
Make a JsonValue representing null
.
pub fn from_array<T>(vm: &'a JsonnetVm, iter: T) -> Self where
T: IntoIterator<Item = JsonValue<'a>>,
[src]
T: IntoIterator<Item = JsonValue<'a>>,
Convert the given list into a JsonValue array.
pub fn from_map<'b, T>(vm: &'a JsonnetVm, iter: T) -> Self where
T: IntoIterator<Item = (&'b CStr, JsonValue<'a>)>,
[src]
T: IntoIterator<Item = (&'b CStr, JsonValue<'a>)>,
Convert the given map into a JsonValue object.
pub fn into_raw(self) -> *mut JsonnetJsonValue
[src]
Transfer ownership to a C caller (presumably a jsonnet function).
If you call this, it is up to you to ensure that the value is freed correctly (using the appropriate jsonnet function), or the memory will leak.
Trait Implementations
Auto Trait Implementations
impl<'a> RefUnwindSafe for JsonValue<'a>
[src]
impl<'a> !Send for JsonValue<'a>
[src]
impl<'a> !Sync for JsonValue<'a>
[src]
impl<'a> Unpin for JsonValue<'a>
[src]
impl<'a> UnwindSafe for JsonValue<'a>
[src]
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,