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 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::Displayorsuper::ToText(cast to string) in the following 2 cases:- Jsonb null is displayed as 4-letter
nullbut treated as sql null here.- This function writes nothing and the caller is responsible for checking
Self::is_jsonb_nullto 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, ty: &ListType) -> Result<ListValue, String>
pub fn to_list(self, ty: &ListType) -> 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<'_>
The display of JsonbRef is pg-compatible format which has slightly different from
serde_json::Value.
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 ToSql for JsonbRef<'_>
impl ToSql for JsonbRef<'_>
Source§fn accepts(ty: &Type) -> bool
fn accepts(ty: &Type) -> bool
Type.Source§fn to_sql_checked(
&self,
ty: &Type,
out: &mut BytesMut,
) -> Result<IsNull, Box<dyn Error + Sync + Send>>
fn to_sql_checked( &self, ty: &Type, out: &mut BytesMut, ) -> Result<IsNull, Box<dyn Error + Sync + Send>>
Source§fn to_sql(
&self,
ty: &Type,
out: &mut BytesMut,
) -> Result<IsNull, Box<dyn Error + Sync + Send>>where
Self: Sized,
fn to_sql(
&self,
ty: &Type,
out: &mut BytesMut,
) -> Result<IsNull, Box<dyn Error + Sync + Send>>where
Self: Sized,
self into the binary format of the specified
Postgres Type, appending it to out. Read more§fn encode_format(&self, _ty: &Type) -> Format
fn encode_format(&self, _ty: &Type) -> Format
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§fn to_text(&self) -> String
fn to_text(&self) -> String
to_text is a special version of to_text_with_type, it convert the scalar to default type
text. E.g. for Int64, it will convert to text as a Int64 type.
We should prefer to use to_text_with_type because it’s more clear and readable. Read moreSource§fn text_display(&self) -> impl Display + '_
fn text_display(&self) -> impl Display + '_
ToText::write.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
§impl<T> BorrowToSql for Twhere
T: ToSql,
impl<T> BorrowToSql for Twhere
T: ToSql,
§fn borrow_to_sql(&self) -> &dyn ToSql
fn borrow_to_sql(&self) -> &dyn ToSql
self as a ToSql trait object.Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<Q, K> Comparable<K> for Q
impl<Q, K> Comparable<K> for Q
§impl<T> Conv for T
impl<T> Conv for T
§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<T> FmtForward for T
impl<T> FmtForward for T
§fn fmt_binary(self) -> FmtBinary<Self>where
Self: Binary,
fn fmt_binary(self) -> FmtBinary<Self>where
Self: Binary,
self to use its Binary implementation when Debug-formatted.§fn fmt_display(self) -> FmtDisplay<Self>where
Self: Display,
fn fmt_display(self) -> FmtDisplay<Self>where
Self: Display,
self to use its Display implementation when
Debug-formatted.§fn fmt_lower_exp(self) -> FmtLowerExp<Self>where
Self: LowerExp,
fn fmt_lower_exp(self) -> FmtLowerExp<Self>where
Self: LowerExp,
self to use its LowerExp implementation when
Debug-formatted.§fn fmt_lower_hex(self) -> FmtLowerHex<Self>where
Self: LowerHex,
fn fmt_lower_hex(self) -> FmtLowerHex<Self>where
Self: LowerHex,
self to use its LowerHex implementation when
Debug-formatted.§fn fmt_octal(self) -> FmtOctal<Self>where
Self: Octal,
fn fmt_octal(self) -> FmtOctal<Self>where
Self: Octal,
self to use its Octal implementation when Debug-formatted.§fn fmt_pointer(self) -> FmtPointer<Self>where
Self: Pointer,
fn fmt_pointer(self) -> FmtPointer<Self>where
Self: Pointer,
self to use its Pointer implementation when
Debug-formatted.§fn fmt_upper_exp(self) -> FmtUpperExp<Self>where
Self: UpperExp,
fn fmt_upper_exp(self) -> FmtUpperExp<Self>where
Self: UpperExp,
self to use its UpperExp implementation when
Debug-formatted.§fn fmt_upper_hex(self) -> FmtUpperHex<Self>where
Self: UpperHex,
fn fmt_upper_hex(self) -> FmtUpperHex<Self>where
Self: UpperHex,
self to use its UpperHex implementation when
Debug-formatted.§fn fmt_list(self) -> FmtList<Self>where
&'a Self: for<'a> IntoIterator,
fn fmt_list(self) -> FmtList<Self>where
&'a Self: for<'a> IntoIterator,
§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> Pipe for Twhere
T: ?Sized,
impl<T> Pipe for Twhere
T: ?Sized,
§fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
§fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
self and passes that borrow into the pipe function. Read more§fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
self and passes that borrow into the pipe function. Read more§fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
§fn pipe_borrow_mut<'a, B, R>(
&'a mut self,
func: impl FnOnce(&'a mut B) -> R,
) -> R
fn pipe_borrow_mut<'a, B, R>( &'a mut self, func: impl FnOnce(&'a mut B) -> R, ) -> R
§fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
self, then passes self.as_ref() into the pipe function.§fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
self, then passes self.as_mut() into the pipe
function.§fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
self, then passes self.deref() into the pipe function.§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<T> SameOrElseExt for Twhere
T: Eq,
impl<T> SameOrElseExt for Twhere
T: Eq,
Source§fn same_or_else(self, other: T, f: impl FnOnce() -> T) -> T
fn same_or_else(self, other: T, f: impl FnOnce() -> T) -> T
self and other are equal, if so, return self, otherwise return the result of f().§impl<T> Scope for T
impl<T> Scope for T
§impl<T> Tap for T
impl<T> Tap for T
§fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
Borrow<B> of a value. Read more§fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
BorrowMut<B> of a value. Read more§fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
AsRef<R> view of a value. Read more§fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
AsMut<R> view of a value. Read more§fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
Deref::Target of a value. Read more§fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
Deref::Target of a value. Read more§fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
.tap() only in debug builds, and is erased in release builds.§fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
.tap_mut() only in debug builds, and is erased in release
builds.§fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
.tap_borrow() only in debug builds, and is erased in release
builds.§fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
.tap_borrow_mut() only in debug builds, and is erased in release
builds.§fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
.tap_ref() only in debug builds, and is erased in release
builds.§fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
.tap_ref_mut() only in debug builds, and is erased in release
builds.§fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
.tap_deref() only in debug builds, and is erased in release
builds.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.