pub struct JsonbRef<'a>(pub(crate) ValueRef<'a>);
Tuple Fields§
§0: ValueRef<'a>
Implementations§
source§impl<'a> JsonbRef<'a>
impl<'a> JsonbRef<'a>
pub fn memcmp_serialize( &self, serializer: &mut Serializer<impl BufMut>, ) -> Result<()>
sourcepub fn value_serialize(&self) -> Vec<u8> ⓘ
pub fn value_serialize(&self) -> Vec<u8> ⓘ
Serialize to a pgwire “BINARY” encoding.
sourcepub const fn empty_string() -> Self
pub const fn empty_string() -> Self
Returns a value for empty string.
sourcepub fn is_jsonb_null(&self) -> bool
pub fn is_jsonb_null(&self) -> bool
Returns true if this is a jsonb null
.
sourcepub fn is_scalar(&self) -> bool
pub fn is_scalar(&self) -> bool
Returns true if this is a jsonb null, boolean, number or string.
sourcepub fn type_name(&self) -> &'static str
pub fn type_name(&self) -> &'static str
Returns the type name of this jsonb.
Possible values are: null
, boolean
, number
, string
, array
, object
.
sourcepub fn as_bool(&self) -> Result<bool, String>
pub fn as_bool(&self) -> Result<bool, String>
If the JSON is a boolean, returns the associated bool.
sourcepub fn as_string(&self) -> Result<String, String>
pub fn as_string(&self) -> Result<String, String>
If the JSON is a string, returns the associated string.
sourcepub fn as_str(&self) -> Result<&str, String>
pub fn as_str(&self) -> Result<&str, String>
If the JSON is a string, returns the associated &str.
sourcepub fn as_number(&self) -> Result<F64, String>
pub fn as_number(&self) -> Result<F64, String>
Attempt to read jsonb as a JSON number.
According to RFC 8259, only number within IEEE 754 binary64 (double precision) has good
interoperability. We do not support arbitrary precision like PostgreSQL numeric
right now.
sourcepub fn force_str<W: Write>(&self, writer: &mut W) -> Result
pub fn force_str<W: Write>(&self, writer: &mut W) -> Result
This is part of the ->>
or #>>
syntax to access a child as string.
- It is not
as_str
, because there is no runtime error when the jsonb type is not string. - It is not same as
std::fmt::Display
orsuper::ToText
(cast to string) in the following 2 cases:- Jsonb null is displayed as 4-letter
null
but treated as sql null here.- This function writes nothing and the caller is responsible for checking
Self::is_jsonb_null
to differentiate it from an empty string.
- This function writes nothing and the caller is responsible for checking
- Jsonb string is displayed with quotes but treated as its inner value here.
- Jsonb null is displayed as 4-letter
pub fn force_string(&self) -> String
pub fn access_object_field(&self, field: &str) -> Option<Self>
pub fn access_array_element(&self, idx: usize) -> Option<Self>
sourcepub fn array_elements(
self,
) -> Result<impl Iterator<Item = JsonbRef<'a>>, String>
pub fn array_elements( self, ) -> Result<impl Iterator<Item = JsonbRef<'a>>, String>
Returns an iterator over the elements if this is an array.
sourcepub fn object_keys(self) -> Result<impl Iterator<Item = &'a str>, String>
pub fn object_keys(self) -> Result<impl Iterator<Item = &'a str>, String>
Returns an iterator over the keys if this is an object.
sourcepub fn object_key_values(
self,
) -> Result<impl Iterator<Item = (&'a str, JsonbRef<'a>)>, String>
pub fn object_key_values( self, ) -> Result<impl Iterator<Item = (&'a str, JsonbRef<'a>)>, String>
Returns an iterator over the key-value pairs if this is an object.
sourcepub fn pretty(self, f: &mut impl Write) -> Result
pub fn pretty(self, f: &mut impl Write) -> Result
Pretty print the jsonb value to the given writer, with 4 spaces indentation.
sourcepub fn to_datum(self, ty: &DataType) -> Result<Datum, String>
pub fn to_datum(self, ty: &DataType) -> Result<Datum, String>
Convert the jsonb value to a datum.
sourcepub fn to_list(self, elem_type: &DataType) -> Result<ListValue, String>
pub fn to_list(self, elem_type: &DataType) -> Result<ListValue, String>
Convert the jsonb value to a list value.
sourcepub fn to_struct(self, ty: &StructType) -> Result<StructValue, String>
pub fn to_struct(self, ty: &StructType) -> Result<StructValue, String>
Convert the jsonb value to a struct value.
pub fn to_map(self, ty: &MapType) -> Result<MapValue, String>
sourcepub fn populate_struct(
self,
ty: &StructType,
base: Option<StructRef<'_>>,
) -> Result<StructValue, String>
pub fn populate_struct( self, ty: &StructType, base: Option<StructRef<'_>>, ) -> Result<StructValue, String>
Expands the top-level JSON object to a row having the struct type of the base
argument.
Trait Implementations§
source§impl Display for JsonbRef<'_>
impl Display for JsonbRef<'_>
The display of JsonbRef
is pg-compatible format which has slightly different from
serde_json::Value
.
source§impl From<JsonbRef<'_>> for ScalarImpl
impl From<JsonbRef<'_>> for ScalarImpl
source§impl<'scalar> From<JsonbRef<'scalar>> for ScalarRefImpl<'scalar>
impl<'scalar> From<JsonbRef<'scalar>> for ScalarRefImpl<'scalar>
source§impl Ord for JsonbRef<'_>
impl Ord for JsonbRef<'_>
source§impl PartialOrd for JsonbRef<'_>
impl PartialOrd for JsonbRef<'_>
source§impl<'a> ScalarRef<'a> for JsonbRef<'a>
impl<'a> ScalarRef<'a> for JsonbRef<'a>
source§type ScalarType = JsonbVal
type ScalarType = JsonbVal
ScalarType
is the owned type of current ScalarRef
.source§fn to_owned_scalar(&self) -> Self::ScalarType
fn to_owned_scalar(&self) -> Self::ScalarType
ScalarRef
to an owned scalar.source§fn hash_scalar<H: Hasher>(&self, state: &mut H)
fn hash_scalar<H: Hasher>(&self, state: &mut H)
source§impl SelfAsScalarRef for JsonbRef<'_>
impl SelfAsScalarRef for JsonbRef<'_>
fn as_scalar_ref(&self) -> Self
source§impl ToBinary for JsonbRef<'_>
impl ToBinary for JsonbRef<'_>
fn to_binary_with_type(&self, _ty: &DataType) -> Result<Bytes, ToBinaryError>
source§impl ToText for JsonbRef<'_>
impl ToText for JsonbRef<'_>
source§fn write<W: Write>(&self, f: &mut W) -> Result
fn write<W: Write>(&self, f: &mut W) -> Result
source§fn write_with_type<W: Write>(&self, _ty: &DataType, f: &mut W) -> Result
fn write_with_type<W: Write>(&self, _ty: &DataType, f: &mut W) -> Result
source§fn to_text_with_type(&self, ty: &DataType) -> String
fn to_text_with_type(&self, ty: &DataType) -> String
source§impl<'scalar> TryFrom<ScalarRefImpl<'scalar>> for JsonbRef<'scalar>
impl<'scalar> TryFrom<ScalarRefImpl<'scalar>> for JsonbRef<'scalar>
source§type Error = ArrayError
type Error = ArrayError
source§fn try_from(val: ScalarRefImpl<'scalar>) -> ArrayResult<Self>
fn try_from(val: ScalarRefImpl<'scalar>) -> ArrayResult<Self>
source§impl WithDataType for JsonbRef<'_>
impl WithDataType for JsonbRef<'_>
source§fn default_data_type() -> DataType
fn default_data_type() -> DataType
DataType
for the rust type.impl<'a> Copy for JsonbRef<'a>
impl<'a> Eq for JsonbRef<'a>
impl<'a> StructuralPartialEq for JsonbRef<'a>
Auto Trait Implementations§
impl<'a> Freeze for JsonbRef<'a>
impl<'a> RefUnwindSafe for JsonbRef<'a>
impl<'a> Send for JsonbRef<'a>
impl<'a> Sync for JsonbRef<'a>
impl<'a> Unpin for JsonbRef<'a>
impl<'a> UnwindSafe for JsonbRef<'a>
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
source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)§impl<Q, K> Comparable<K> for Q
impl<Q, K> Comparable<K> for Q
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key
and return true
if they are equal.source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key
and return true
if they are equal.§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
§impl<T> FutureExt for T
impl<T> FutureExt for T
§fn with_context(self, otel_cx: Context) -> WithContext<Self>
fn with_context(self, otel_cx: Context) -> WithContext<Self>
§fn with_current_context(self) -> WithContext<Self>
fn with_current_context(self) -> WithContext<Self>
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
source§impl<T> Instrument for T
impl<T> Instrument for T
source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
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>
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>
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 moresource§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T
in a tonic::Request
§impl<T> IntoResult<T> for T
impl<T> IntoResult<T> for T
type Err = Infallible
fn into_result(self) -> Result<T, <T as IntoResult<T>>::Err>
source§impl<M> MetricVecRelabelExt for M
impl<M> MetricVecRelabelExt for M
source§fn relabel(
self,
metric_level: MetricLevel,
relabel_threshold: MetricLevel,
) -> RelabeledMetricVec<M>
fn relabel( self, metric_level: MetricLevel, relabel_threshold: MetricLevel, ) -> RelabeledMetricVec<M>
RelabeledMetricVec::with_metric_level
.source§fn relabel_n(
self,
metric_level: MetricLevel,
relabel_threshold: MetricLevel,
relabel_num: usize,
) -> RelabeledMetricVec<M>
fn relabel_n( self, metric_level: MetricLevel, relabel_threshold: MetricLevel, relabel_num: usize, ) -> RelabeledMetricVec<M>
RelabeledMetricVec::with_metric_level_relabel_n
.source§fn relabel_debug_1(
self,
relabel_threshold: MetricLevel,
) -> RelabeledMetricVec<M>
fn relabel_debug_1( self, relabel_threshold: MetricLevel, ) -> RelabeledMetricVec<M>
RelabeledMetricVec::with_metric_level_relabel_n
with metric_level
set to
MetricLevel::Debug
and relabel_num
set to 1.§impl<T> Pointable for T
impl<T> Pointable for T
source§impl<T> ToOwnedDatum for Twhere
T: Into<ScalarImpl>,
impl<T> ToOwnedDatum for Twhere
T: Into<ScalarImpl>,
source§fn to_owned_datum(self) -> Option<ScalarImpl>
fn to_owned_datum(self) -> Option<ScalarImpl>
Datum
.