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
impl JsonValue
Sourcepub fn new(value: SerdeJsonValue) -> CoreResult<Self>
pub fn new(value: SerdeJsonValue) -> CoreResult<Self>
Build a validated JSON value from an owned serde-json value.
Sourcepub fn parse_str(text: &str) -> CoreResult<Self>
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.
Sourcepub fn as_serde(&self) -> &SerdeJsonValue
pub fn as_serde(&self) -> &SerdeJsonValue
Borrow the underlying serde-json value.
Sourcepub fn as_arc(&self) -> Arc<SerdeJsonValue>
pub fn as_arc(&self) -> Arc<SerdeJsonValue>
Clone the shared JSON storage.
Sourcepub fn to_canonical_string(&self) -> String
pub fn to_canonical_string(&self) -> String
Return a stable compact JSON rendering with object keys sorted.
Sourcepub fn json_type_name(&self) -> &'static str
pub fn json_type_name(&self) -> &'static str
Return the JSON data-model type name.
Sourcepub fn contains(&self, candidate: &Self) -> bool
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.
Sourcepub fn path_exists(&self, path: &[JsonPathSelector]) -> bool
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.
Sourcepub fn path_value(&self, path: &[JsonPathSelector]) -> Option<Self>
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.
Sourcepub fn path_value_ref(
&self,
path: &[JsonPathSelector],
) -> Option<JsonValueRef<'_>>
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.
Sourcepub fn path_contains(&self, path: &[JsonPathSelector], candidate: &Self) -> bool
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.
Sourcepub fn merge_patch(&self, patch: &Self) -> CoreResult<Self>
pub fn merge_patch(&self, patch: &Self) -> CoreResult<Self>
Sourcepub fn apply_patch(&self, patch: &Self) -> CoreResult<Self>
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<'de> Deserialize<'de> for JsonValue
impl<'de> Deserialize<'de> for JsonValue
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>,
impl StructuralPartialEq for JsonValue
Auto Trait Implementations§
impl Freeze for JsonValue
impl RefUnwindSafe for JsonValue
impl Send for JsonValue
impl Sync for JsonValue
impl Unpin for JsonValue
impl UnsafeUnpin for JsonValue
impl UnwindSafe for JsonValue
Blanket Implementations§
Source§impl<T> ArchivePointee for T
impl<T> ArchivePointee for T
Source§type ArchivedMetadata = ()
type ArchivedMetadata = ()
Source§fn pointer_metadata(
_: &<T as ArchivePointee>::ArchivedMetadata,
) -> <T as Pointee>::Metadata
fn pointer_metadata( _: &<T as ArchivePointee>::ArchivedMetadata, ) -> <T as Pointee>::Metadata
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
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>,
Source§impl<T> LayoutRaw for T
impl<T> LayoutRaw for T
Source§fn layout_raw(_: <T as Pointee>::Metadata) -> Result<Layout, LayoutError>
fn layout_raw(_: <T as Pointee>::Metadata) -> Result<Layout, LayoutError>
Source§impl<T, N1, N2> Niching<NichedOption<T, N1>> for N2
impl<T, N1, N2> Niching<NichedOption<T, N1>> for N2
Source§unsafe fn is_niched(niched: *const NichedOption<T, N1>) -> bool
unsafe fn is_niched(niched: *const NichedOption<T, N1>) -> bool
Source§fn resolve_niched(out: Place<NichedOption<T, N1>>)
fn resolve_niched(out: Place<NichedOption<T, N1>>)
out indicating that a T is niched.