pub struct JanssonValue { /* private fields */ }Expand description
A safe wrapper for a Jansson JSON value. Automatically increases and decreases the refcount of the underlying value when cloned/dropped.
Implementations§
Source§impl JanssonValue
impl JanssonValue
Sourcepub unsafe fn from_and_incref(ptr: *mut RawJanssonValue) -> Option<Self>
pub unsafe fn from_and_incref(ptr: *mut RawJanssonValue) -> Option<Self>
Creates a JanssonValue owning the given raw pointer, incrementing the reference count.
Sourcepub unsafe fn from_raw(ptr: *mut RawJanssonValue) -> Option<Self>
pub unsafe fn from_raw(ptr: *mut RawJanssonValue) -> Option<Self>
Creates a JanssonValue owning the given raw pointer. Does not increment the reference count, but the
JanssonValue’s destructor will decrement the reference count.
Sourcepub fn into_raw(self) -> *mut RawJanssonValue
pub fn into_raw(self) -> *mut RawJanssonValue
Transfers ownership of this value to this pointer. The consumer of the pointer is responsible for calling json_decref on it later.
Sourcepub fn as_mut_ref(&mut self) -> &mut RawJanssonValue
pub fn as_mut_ref(&mut self) -> &mut RawJanssonValue
Gets the reference backing this value without taking ownership.
Sourcepub fn from_str(
input: &str,
decoding_flags: JanssonDecodingFlags,
) -> Result<Self, Box<dyn Error + Send + Sync>>
pub fn from_str( input: &str, decoding_flags: JanssonDecodingFlags, ) -> Result<Self, Box<dyn Error + Send + Sync>>
Decodes a JSON string slice into a Jansson value, returning an error if decoding fails.
Sourcepub fn from_cstr(
input: &CStr,
decoding_flags: JanssonDecodingFlags,
) -> Result<Self, Box<dyn Error + Send + Sync>>
pub fn from_cstr( input: &CStr, decoding_flags: JanssonDecodingFlags, ) -> Result<Self, Box<dyn Error + Send + Sync>>
Decodes a JSON C-style string into a Jansson value, returning an error if decoding fails.
Sourcepub fn to_libcstring(&self, encoding_flags: JanssonEncodingFlags) -> LibcString
pub fn to_libcstring(&self, encoding_flags: JanssonEncodingFlags) -> LibcString
Encodes this Jansson value as a JSON owned C-style string.