Struct SerializeFields

Source
pub struct SerializeFields<'a, T, S>(pub &'a T, pub &'a S);
Expand description

A wrapper struct that combines data with a field selector for serialization.

This is the core type that enables dynamic field selection. It wraps your data and a field selector, implementing Serialize to only include enabled fields.

§Type Parameters

  • T: The type of data being serialized
  • S: The type of field selector (typically generated by the derive macro)

§Examples

let wrapper = SerializeFields(&user, &selector);
let json = serde_json::to_string(&wrapper).unwrap();

Tuple Fields§

§0: &'a T§1: &'a S

Trait Implementations§

Source§

impl<'a, T, S> Serialize for SerializeFields<'a, Option<T>, S>
where T: SerializeFieldsTrait<FieldSelector = S>, S: FieldSelector,

Source§

fn serialize<Se>(&self, serializer: Se) -> Result<Se::Ok, Se::Error>
where Se: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl<'a, T, S> Serialize for SerializeFields<'a, T, S>
where T: SerializeFieldsTrait<FieldSelector = S>, S: FieldSelector,

Source§

fn serialize<Se>(&self, serializer: Se) -> Result<Se::Ok, Se::Error>
where Se: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl<'a, T, S> Serialize for SerializeFields<'a, Vec<T>, S>
where T: SerializeFieldsTrait<FieldSelector = S>, S: FieldSelector,

Source§

fn serialize<Se>(&self, serializer: Se) -> Result<Se::Ok, Se::Error>
where Se: Serializer,

Serialize this value into the given Serde serializer. Read more

Auto Trait Implementations§

§

impl<'a, T, S> Freeze for SerializeFields<'a, T, S>

§

impl<'a, T, S> RefUnwindSafe for SerializeFields<'a, T, S>

§

impl<'a, T, S> Send for SerializeFields<'a, T, S>
where T: Sync, S: Sync,

§

impl<'a, T, S> Sync for SerializeFields<'a, T, S>
where T: Sync, S: Sync,

§

impl<'a, T, S> Unpin for SerializeFields<'a, T, S>

§

impl<'a, T, S> UnwindSafe for SerializeFields<'a, T, S>

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

Source§

fn from(t: T) -> T

Returns the argument unchanged.

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, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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.