Path: blob/main/crates/bevy_reflect/src/serde/de/structs.rs
9395 views
use crate::{1serde::de::struct_utils::{visit_struct, visit_struct_seq},2structs::{DynamicStruct, StructInfo},3TypeRegistration, TypeRegistry,4};5use core::{fmt, fmt::Formatter};6use serde::de::{MapAccess, SeqAccess, Visitor};78use super::ReflectDeserializerProcessor;910/// A [`Visitor`] for deserializing [`Struct`] values.11///12/// [`Struct`]: crate::structs::Struct13pub(super) struct StructVisitor<'a, P> {14pub struct_info: &'static StructInfo,15pub registration: &'a TypeRegistration,16pub registry: &'a TypeRegistry,17pub processor: Option<&'a mut P>,18}1920impl<'de, P: ReflectDeserializerProcessor> Visitor<'de> for StructVisitor<'_, P> {21type Value = DynamicStruct;2223fn expecting(&self, formatter: &mut Formatter) -> fmt::Result {24formatter.write_str("reflected struct value")25}2627fn visit_seq<A>(self, mut seq: A) -> Result<Self::Value, A::Error>28where29A: SeqAccess<'de>,30{31visit_struct_seq(32&mut seq,33self.struct_info,34self.registration,35self.registry,36self.processor,37)38}3940fn visit_map<V>(self, mut map: V) -> Result<Self::Value, V::Error>41where42V: MapAccess<'de>,43{44visit_struct(45&mut map,46self.struct_info,47self.registration,48self.registry,49self.processor,50)51}52}535455