Skip to main content

RawJson

Struct RawJson 

Source
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

Source

pub fn from_vec(bytes: Vec<u8>) -> Self

Wrap owned bytes (caller ensures a single JSON value).

Source

pub fn from_slice(slice: &[u8]) -> Self

Copy a value span.

Source

pub fn as_bytes(&self) -> &[u8] ⓘ

Borrow the raw value bytes.

Source

pub fn into_bytes(self) -> Vec<u8> ⓘ

Consume into bytes.

Source

pub fn len(&self) -> usize

Length of the value on the wire.

Source

pub fn is_empty(&self) -> bool

Source

pub fn as_doc(&self) -> TypedDocRef<'_>

Read as a TypedDocRef (path ops relative to this subtree).

Source

pub fn as_view<V: JsonView>(&self) -> Result<V, Error>

Decode this subtree as a JsonView.

Source

pub fn get<T: FromJsonSlice>(&self, path: &str) -> Result<T, Error>

Decode a path inside this subtree.

Trait Implementations§

Source§

impl AsRef<[u8]> for RawJson

Source§

fn as_ref(&self) -> &[u8] ⓘ

Converts this type into a shared reference of the (usually inferred) input type.
Source§

impl Clone for RawJson

Source§

fn clone(&self) -> Self

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 RawJson

Source§

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

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

impl Default for RawJson

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl Eq for RawJson

Source§

impl From<&[u8]> for RawJson

Source§

fn from(slice: &[u8]) -> Self

Converts to this type from the input type.
Source§

impl From<Vec<u8>> for RawJson

Source§

fn from(bytes: Vec<u8>) -> Self

Converts to this type from the input type.
Source§

impl FromJsonSlice for RawJson

Source§

fn from_json_slice(slice: &[u8]) -> Option<Self>

Copy the value span (including surrounding structure). Trims outer whitespace only.

Source§

impl Hash for RawJson

Source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl JsonDoc for RawJson

Source§

fn as_json_bytes(&self) -> &[u8] ⓘ

Raw JSON bytes for this document (or subdocument).
Source§

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>

Locate using pre-parsed path segments (hot loops / reused Path).
Source§

fn get_raw_at(&self, path: &Path) -> Result<&[u8], Error>

Locate using an owned Path.
Source§

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>

Decode using pre-parsed segments.
Source§

fn get_at<T: FromJsonSlice>(&self, path: &Path) -> Result<T, Error>

Decode using an owned Path.
Source§

fn get_opt<T: FromJsonSlice>(&self, path: &str) -> Result<Option<T>, Error>

Like get, but Error::PathNotFound → Ok(None). Read more
Source§

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>

Zero-copy string content for a JSON string without escapes. Read more
Source§

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>

Zero-copy string using an owned Path.
Source§

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>

Open-document JsonView projection of the whole buffer.
Source§

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>

Nested view using pre-parsed segments.
Source§

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>

Iterator over raw element spans of the array at path. Read more
Source§

fn each_with<F>(&self, path: &str, f: F) -> Result<(), Error>
where F: FnMut(&[u8]) -> 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>
where T: FromJsonSlice, F: FnMut(T) -> Result<(), Error>,

Stream each array element decoded as T: FromJsonSlice (whole element).
Source§

fn each_view_with<V, F>(&self, path: &str, f: F) -> Result<(), Error>
where V: JsonView, F: FnMut(V) -> Result<(), Error>,

Stream each array element as a JsonView. Read more
Source§

fn each_get<T, F>( &self, array_path: &str, field_path: &str, f: F, ) -> Result<(), Error>
where T: FromJsonSlice, F: FnMut(T) -> 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>

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>

Collect a relative field from each array element.
Source§

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>

Classify the root JSON value (object, array, primitive, …).
Source§

fn is_object(&self) -> Result<bool, Error>

true when the root value is a JSON object.
Source§

fn is_array(&self) -> Result<bool, Error>

true when the root value is a JSON array.
Source§

fn root_elems(&self) -> Result<ArrayElems<'_>, Error>

Stream root array elements (document is [...]).
Source§

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>

true if the path exists and is JSON null.
Source§

fn get_nullable<T: FromJsonSlice>(&self, path: &str) -> Result<Option<T>, Error>

Decode a path, mapping missing and null to Ok(None). Read more
Source§

fn object_entries(&self) -> Result<ObjectEntries<'_>, Error>

Iterate object members at the document root ({"k":...}). Read more
Source§

fn object_entries_at(&self, path: &str) -> Result<ObjectEntries<'_>, Error>

Iterate object members at path.
Source§

impl PartialEq for RawJson

Source§

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

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

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

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for RawJson

Source§

impl ToJsonBytes for RawJson

Source§

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>)

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§

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> 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> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

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

Source§

fn from_ref(input: &T) -> T

Converts to this type from a reference to the input type.
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> IntoEither for T

Source§

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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
where F: FnOnce(&Self) -> bool,

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
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
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 = !

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

fn try_from(value: U) -> Result<T, !>

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.