pub struct ViewData { /* private fields */ }Expand description
A view’s data: a map of names to values, each serialized to JSON when it is added. Rendering the view reports any value that couldn’t be serialized.
Build it with [data!], or from any Serialize value that serializes to a map, such as a
struct.
Implementations§
Source§impl ViewData
impl ViewData
Sourcepub fn insert(&mut self, name: impl Into<String>, value: impl Serialize)
pub fn insert(&mut self, name: impl Into<String>, value: impl Serialize)
Adds a value under a name, replacing any value with the same name.
Sourcepub fn get(&self, name: &str) -> Option<&Value>
pub fn get(&self, name: &str) -> Option<&Value>
The serialized value under name, or None when there’s no value or the value failed to
serialize.
Trait Implementations§
Source§impl Serialize for ViewData
View data can nest, as in data! { orders => [data! { total => 5 }] }. A value that couldn’t
be serialized fails the serialization.
impl Serialize for ViewData
View data can nest, as in data! { orders => [data! { total => 5 }] }. A value that couldn’t
be serialized fails the serialization.
Source§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,
Serialize this value into the given Serde serializer. Read more
Auto Trait Implementations§
impl Forget for ViewData
impl Freeze for ViewData
impl Move for ViewData
impl RefUnwindSafe for ViewData
impl Send for ViewData
impl Sync for ViewData
impl Unpin for ViewData
impl UnsafeUnpin for ViewDatawhere
*const u8 is !null: UnsafeUnpin,
PhantomData<usize>: UnsafeUnpin,
PhantomData<Bucket<String, Value>>: UnsafeUnpin,
*const ArcInner<str> is !null: UnsafeUnpin,
PhantomData<ArcInner<str>>: UnsafeUnpin,
impl UnwindSafe for ViewData
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
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> ErasedDestructor for Twhere
T: 'static,
Source§impl<K> ForeignKey<K> for K
impl<K> ForeignKey<K> for K
Source§impl<T> FutureExt for T
impl<T> FutureExt for T
Source§fn with_context(self, otel_cx: Context) -> WithContext<Self> ⓘ
fn with_context(self, otel_cx: Context) -> WithContext<Self> ⓘ
Source§fn with_current_context(self) -> WithContext<Self> ⓘ
fn with_current_context(self) -> WithContext<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> ⓘ
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 moreCreates a shared type from an unshared type.
Source§impl<T> IntoViewData for Twhere
T: Serialize,
impl<T> IntoViewData for Twhere
T: Serialize,
Source§fn into_view_data(self) -> ViewData
fn into_view_data(self) -> ViewData
Converts the value into view data.