Struct JsObject
pub struct JsObject(/* private fields */);js and std only.Expand description
An immutable, insertion-ordered snapshot of a js object.
Keys are unique: constructing one from entries with duplicate keys collapses them like a js object literal (first position, last value).
The backing storage is shared, making clones O(1), and all
conversions out of it are pull-based: nothing beyond the initial
boundary snapshot is computed unless you ask for it. The concrete
representation is private so it can evolve (e.g. become lazier)
without breaking changes.
Implementations§
§impl JsObject
impl JsObject
pub fn deserialize_into<T>(&self) -> Result<T, JsError>where
T: DeserializeOwned,
pub fn deserialize_into<T>(&self) -> Result<T, JsError>where
T: DeserializeOwned,
Deserialize this object into any serde-capable type.
§impl JsObject
impl JsObject
pub fn get(&self, key: impl AsRef<str>) -> Option<&JsValue>
pub fn get(&self, key: impl AsRef<str>) -> Option<&JsValue>
The value of the property with the given key, if any.
pub fn contains_key(&self, key: impl AsRef<str>) -> bool
pub fn contains_key(&self, key: impl AsRef<str>) -> bool
Returns true if this object has a property with the given key.
pub fn keys(&self) -> impl Iterator<Item = &JsStr>
pub fn keys(&self) -> impl Iterator<Item = &JsStr>
Iterate over the property keys of this object, in insertion order.
Trait Implementations§
§impl<K, V> FromIterator<(K, V)> for JsObject
impl<K, V> FromIterator<(K, V)> for JsObject
§fn from_iter<I>(iter: I) -> JsObjectwhere
I: IntoIterator<Item = (K, V)>,
fn from_iter<I>(iter: I) -> JsObjectwhere
I: IntoIterator<Item = (K, V)>,
Duplicate keys collapse like a js object literal: the first occurrence keeps its position, the last value wins.
§impl<'a> IntoIterator for &'a JsObject
impl<'a> IntoIterator for &'a JsObject
§impl Serialize for JsObject
impl Serialize for JsObject
§fn serialize<S>(
&self,
serializer: S,
) -> Result<<S as Serializer>::Ok, <S as Serializer>::Error>where
S: Serializer,
fn serialize<S>(
&self,
serializer: S,
) -> Result<<S as Serializer>::Ok, <S as Serializer>::Error>where
S: Serializer,
impl StructuralPartialEq for JsObject
Auto Trait Implementations§
impl Freeze for JsObject
impl RefUnwindSafe for JsObject
impl Send for JsObject
impl Sync for JsObject
impl Unpin for JsObject
impl UnsafeUnpin for JsObject
impl UnwindSafe for JsObject
Blanket Implementations§
§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
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<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§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> 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 more§impl<T> IntoJsGlobal for T
impl<T> IntoJsGlobal for T
§fn into_global_entry(self) -> JsGlobal
fn into_global_entry(self) -> JsGlobal
§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T in a rama_grpc::Request§impl<T> JsFnOutput<ValueOutput> for T
impl<T> JsFnOutput<ValueOutput> for T
§fn into_js_fn_output(self) -> Result<JsValue, JsError>
fn into_js_fn_output(self) -> Result<JsValue, JsError>
§impl<T> Pointable for T
impl<T> Pointable for T
§impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt for Twhere
T: ?Sized,
§fn and<P, B, E>(self, other: P) -> And<T, P>
fn and<P, B, E>(self, other: P) -> And<T, P>
Policy that returns Action::Follow only if self and other return
Action::Follow. Read more