Skip to main content

JsonValue

Struct JsonValue 

Source
pub struct JsonValue { /* private fields */ }
Expand description

Native JSON payload stored as a first-class crate::Value.

JsonValue validates once at construction and deserialization so every engine layer can assume a finite JSON data-model value whose strings and container cardinalities stay inside the implementation-defined GQL caps.

Implementations§

Source§

impl JsonValue

Source

pub fn new(value: SerdeJsonValue) -> CoreResult<Self>

Build a validated JSON value from an owned serde-json value.

Source

pub fn parse_str(text: &str) -> CoreResult<Self>

Parse and validate a JSON value from text.

§Errors

Returns CoreError::JsonParse when text is not valid JSON, or the usual value-limit errors when the parsed value exceeds engine caps.

Source

pub fn as_serde(&self) -> &SerdeJsonValue

Borrow the underlying serde-json value.

Source

pub fn as_arc(&self) -> Arc<SerdeJsonValue>

Clone the shared JSON storage.

Source

pub fn to_canonical_string(&self) -> String

Return a stable compact JSON rendering with object keys sorted.

Source

pub fn json_type_name(&self) -> &'static str

Return the JSON data-model type name.

Source

pub fn contains(&self, candidate: &Self) -> bool

Return true when this JSON value recursively contains candidate.

Objects contain candidates whose keys are present and whose values are themselves contained. Arrays contain array candidates when each candidate element is contained by at least one target element. A scalar or object candidate also matches any containing target array element.

Source

pub fn path_exists(&self, path: &[JsonPathSelector]) -> bool

Return true when every selector in path resolves inside this value.

Stored-value shape mismatches return false. This makes the helper useful for heterogeneous graph scans where one malformed document should not abort the entire candidate search.

Source

pub fn path_value(&self, path: &[JsonPathSelector]) -> Option<Self>

Return the JSON subvalue selected by path.

Stored-value shape mismatches return None. A selected JSON null still returns Some(JsonValue), which lets callers distinguish present null values from absent paths.

Source

pub fn path_value_ref( &self, path: &[JsonPathSelector], ) -> Option<JsonValueRef<'_>>

Borrow the JSON subvalue selected by path.

Stored-value shape mismatches return None. A selected JSON null still returns Some(JsonValueRef), which lets callers distinguish present null values from absent paths without cloning the subvalue.

Source

pub fn path_contains(&self, path: &[JsonPathSelector], candidate: &Self) -> bool

Return true when path selects a JSON value that contains candidate.

Stored-value shape mismatches return false, matching Self::path_exists. Containment follows Self::contains semantics on the selected subvalue.

Source

pub fn merge_patch(&self, patch: &Self) -> CoreResult<Self>

Return the result of applying an RFC 7396 JSON Merge Patch document.

The operation is copy-on-write: this value and patch are left unchanged, and the merged result is validated as a fresh JsonValue.

§Errors

Returns the usual value-limit errors if the merged result exceeds engine caps.

Source

pub fn apply_patch(&self, patch: &Self) -> CoreResult<Self>

Return the result of applying an RFC 6902 JSON Patch document.

The operation is atomic from the caller’s perspective: this value and patch are left unchanged, and an invalid patch returns an error without exposing any intermediate document state.

§Errors

Returns CoreError::JsonPatch when the patch document is malformed or an operation fails. Returns the usual value-limit errors if the patched result exceeds engine caps.

Trait Implementations§

Source§

impl Clone for JsonValue

Source§

fn clone(&self) -> JsonValue

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for JsonValue

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<'de> Deserialize<'de> for JsonValue

Source§

fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
where D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl From<JsonValue> for Value

Source§

fn from(value: JsonValue) -> Self

Converts to this type from the input type.
Source§

impl PartialEq for JsonValue

Source§

fn eq(&self, other: &JsonValue) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Serialize for JsonValue

Source§

fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
where S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl StructuralPartialEq for JsonValue

Source§

impl TryFrom<Value> for JsonValue

Source§

type Error = CoreError

The type returned in the event of a conversion error.
Source§

fn try_from(value: SerdeJsonValue) -> Result<Self, Self::Error>

Performs the conversion.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> ArchivePointee for T

Source§

type ArchivedMetadata = ()

The archived version of the pointer metadata for this type.
Source§

fn pointer_metadata( _: &<T as ArchivePointee>::ArchivedMetadata, ) -> <T as Pointee>::Metadata

Converts some archived metadata to the pointer metadata for itself.
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> LayoutRaw for T

Source§

fn layout_raw(_: <T as Pointee>::Metadata) -> Result<Layout, LayoutError>

Returns the layout of the type.
Source§

impl<T, N1, N2> Niching<NichedOption<T, N1>> for N2
where T: SharedNiching<N1, N2>, N1: Niching<T>, N2: Niching<T>,

Source§

unsafe fn is_niched(niched: *const NichedOption<T, N1>) -> bool

Returns whether the given value has been niched. Read more
Source§

fn resolve_niched(out: Place<NichedOption<T, N1>>)

Writes data to out indicating that a T is niched.
Source§

impl<T> Pointee for T

Source§

type Metadata = ()

The metadata type for pointers and references to this type.
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.