pub struct RawJson { /* private fields */ }Expand description
Owned raw JSON value bytes (object, array, string, number, bool, or null).
Preserves the on-wire form; no parse tree. Cheap to pass through open documents and re-attach with mutators / builders.
Implementations§
Source§impl RawJson
impl RawJson
Sourcepub fn from_slice(slice: &[u8]) -> Self
pub fn from_slice(slice: &[u8]) -> Self
Copy a value span.
Sourcepub fn into_bytes(self) -> Vec<u8> ⓘ
pub fn into_bytes(self) -> Vec<u8> ⓘ
Consume into bytes.
pub fn is_empty(&self) -> bool
Sourcepub fn as_doc(&self) -> TypedDocRef<'_>
pub fn as_doc(&self) -> TypedDocRef<'_>
Read as a TypedDocRef (path ops relative to this subtree).
Trait Implementations§
impl Eq for RawJson
Source§impl FromJsonSlice for RawJson
impl FromJsonSlice for RawJson
Source§fn from_json_slice(slice: &[u8]) -> Option<Self>
fn from_json_slice(slice: &[u8]) -> Option<Self>
Copy the value span (including surrounding structure). Trims outer whitespace only.
Source§impl JsonDoc for RawJson
impl JsonDoc for RawJson
Source§fn as_json_bytes(&self) -> &[u8] ⓘ
fn as_json_bytes(&self) -> &[u8] ⓘ
Raw JSON bytes for this document (or subdocument).
Source§fn get_raw(&self, path: &str) -> Result<&[u8], Error>
fn get_raw(&self, path: &str) -> Result<&[u8], Error>
Locate a path and return the raw value span (zero-copy).
Source§fn get_raw_path(&self, path: &[PathSegment<'_>]) -> Result<&[u8], Error>
fn get_raw_path(&self, path: &[PathSegment<'_>]) -> Result<&[u8], Error>
Locate using pre-parsed path segments (hot loops / reused
Path).Source§fn get<T: FromJsonSlice>(&self, path: &str) -> Result<T, Error>
fn get<T: FromJsonSlice>(&self, path: &str) -> Result<T, Error>
Decode a path into an owned Rust value via
FromJsonSlice.Source§fn get_path<T: FromJsonSlice>(
&self,
path: &[PathSegment<'_>],
) -> Result<T, Error>
fn get_path<T: FromJsonSlice>( &self, path: &[PathSegment<'_>], ) -> Result<T, Error>
Decode using pre-parsed segments.
Source§fn get_at<T: FromJsonSlice>(&self, path: &Path) -> Result<T, Error>
fn get_at<T: FromJsonSlice>(&self, path: &Path) -> Result<T, Error>
Decode using an owned
Path.Source§fn contains(&self, path: &str) -> Result<bool, Error>
fn contains(&self, path: &str) -> Result<bool, Error>
true if the path exists (value span found), without decoding.Source§fn get_str(&self, path: &str) -> Result<&str, Error>
fn get_str(&self, path: &str) -> Result<&str, Error>
Zero-copy string content for a JSON string without escapes. Read more
Source§fn get_str_path(&self, path: &[PathSegment<'_>]) -> Result<&str, Error>
fn get_str_path(&self, path: &[PathSegment<'_>]) -> Result<&str, Error>
Zero-copy string using pre-parsed segments.
Source§fn get_str_at(&self, path: &Path) -> Result<&str, Error>
fn get_str_at(&self, path: &Path) -> Result<&str, Error>
Zero-copy string using an owned
Path.Source§fn get_pointer<T: FromJsonSlice>(&self, pointer: &str) -> Result<T, Error>
fn get_pointer<T: FromJsonSlice>(&self, pointer: &str) -> Result<T, Error>
RFC 6901 JSON Pointer decode (
"/a~1b/0").Source§fn as_view<V: JsonView>(&self) -> Result<V, Error>
fn as_view<V: JsonView>(&self) -> Result<V, Error>
Open-document
JsonView projection of the whole buffer.Source§fn view_at(&self, path: &str) -> Result<TypedDocRef<'_>, Error>
fn view_at(&self, path: &str) -> Result<TypedDocRef<'_>, Error>
Borrow the value at
path as a nested TypedDocRef (subtree as root).Source§fn view_at_path(
&self,
path: &[PathSegment<'_>],
) -> Result<TypedDocRef<'_>, Error>
fn view_at_path( &self, path: &[PathSegment<'_>], ) -> Result<TypedDocRef<'_>, Error>
Nested view using pre-parsed segments.
Source§fn array_len(&self, path: &str) -> Result<usize, Error>
fn array_len(&self, path: &str) -> Result<usize, Error>
Number of elements in the array at
path.Source§fn elems(&self, path: &str) -> Result<ArrayElems<'_>, Error>
fn elems(&self, path: &str) -> Result<ArrayElems<'_>, Error>
Iterator over raw element spans of the array at
path. Read moreSource§fn each_with<F>(&self, path: &str, f: F) -> Result<(), Error>
fn each_with<F>(&self, path: &str, f: F) -> Result<(), Error>
Stream each array element as a raw span into
f.Source§fn each_with_decoded<T, F>(&self, path: &str, f: F) -> Result<(), Error>
fn each_with_decoded<T, F>(&self, path: &str, f: F) -> Result<(), Error>
Stream each array element decoded as
T: FromJsonSlice (whole element).Source§fn each_get<T, F>(
&self,
array_path: &str,
field_path: &str,
f: F,
) -> Result<(), Error>
fn each_get<T, F>( &self, array_path: &str, field_path: &str, f: F, ) -> Result<(), Error>
Stream a relative field from each array element (path parsed once). Read more
Source§fn collect_each<T: FromJsonSlice>(&self, path: &str) -> Result<Vec<T>, Error>
fn collect_each<T: FromJsonSlice>(&self, path: &str) -> Result<Vec<T>, Error>
Collect array elements into
Vec<T> (explicit materialize).Source§fn collect_each_get<T: FromJsonSlice>(
&self,
array_path: &str,
field_path: &str,
) -> Result<Vec<T>, Error>
fn collect_each_get<T: FromJsonSlice>( &self, array_path: &str, field_path: &str, ) -> Result<Vec<T>, Error>
Collect a relative field from each array element.
Source§fn collect_each_view<V: JsonView>(&self, path: &str) -> Result<Vec<V>, Error>
fn collect_each_view<V: JsonView>(&self, path: &str) -> Result<Vec<V>, Error>
Collect array elements as views into
Vec<V>.Source§fn root_kind(&self) -> Result<RootKind, Error>
fn root_kind(&self) -> Result<RootKind, Error>
Classify the root JSON value (object, array, primitive, …).
Source§fn root_elems(&self) -> Result<ArrayElems<'_>, Error>
fn root_elems(&self) -> Result<ArrayElems<'_>, Error>
Stream root array elements (document is
[...]).Source§fn presence(&self, path: &str) -> Result<Presence, Error>
fn presence(&self, path: &str) -> Result<Presence, Error>
Presence of a path: missing, JSON
null, or a real value.Source§fn is_null(&self, path: &str) -> Result<bool, Error>
fn is_null(&self, path: &str) -> Result<bool, Error>
true if the path exists and is JSON null.Source§fn get_nullable<T: FromJsonSlice>(&self, path: &str) -> Result<Option<T>, Error>
fn get_nullable<T: FromJsonSlice>(&self, path: &str) -> Result<Option<T>, Error>
Decode a path, mapping missing and null to
Ok(None). Read moreSource§fn object_entries(&self) -> Result<ObjectEntries<'_>, Error>
fn object_entries(&self) -> Result<ObjectEntries<'_>, Error>
Iterate object members at the document root (
{"k":...}). Read moreSource§fn object_entries_at(&self, path: &str) -> Result<ObjectEntries<'_>, Error>
fn object_entries_at(&self, path: &str) -> Result<ObjectEntries<'_>, Error>
Iterate object members at
path.impl StructuralPartialEq for RawJson
Source§impl ToJsonBytes for RawJson
impl ToJsonBytes for RawJson
Source§fn to_json_bytes(&self) -> Vec<u8> ⓘ
fn to_json_bytes(&self) -> Vec<u8> ⓘ
Serializes the value into a raw JSON byte vector. Read more
Source§fn write_json_bytes(&self, out: &mut Vec<u8>)
fn write_json_bytes(&self, out: &mut Vec<u8>)
Append the JSON encoding of
self into out (avoids an intermediate Vec
when the implementor overrides this; default uses to_json_bytes).Auto Trait Implementations§
impl Freeze for RawJson
impl RefUnwindSafe for RawJson
impl Send for RawJson
impl Sync for RawJson
impl Unpin for RawJson
impl UnsafeUnpin for RawJson
impl UnwindSafe for RawJson
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more