Path: blob/main/crates/bevy_reflect/src/serde/de/structs.rs
6600 views
use crate::{1serde::de::struct_utils::{visit_struct, visit_struct_seq},2DynamicStruct, StructInfo, TypeRegistration, TypeRegistry,3};4use core::{fmt, fmt::Formatter};5use serde::de::{MapAccess, SeqAccess, Visitor};67use super::ReflectDeserializerProcessor;89/// A [`Visitor`] for deserializing [`Struct`] values.10///11/// [`Struct`]: crate::Struct12pub(super) struct StructVisitor<'a, P> {13pub struct_info: &'static StructInfo,14pub registration: &'a TypeRegistration,15pub registry: &'a TypeRegistry,16pub processor: Option<&'a mut P>,17}1819impl<'de, P: ReflectDeserializerProcessor> Visitor<'de> for StructVisitor<'_, P> {20type Value = DynamicStruct;2122fn expecting(&self, formatter: &mut Formatter) -> fmt::Result {23formatter.write_str("reflected struct value")24}2526fn visit_seq<A>(self, mut seq: A) -> Result<Self::Value, A::Error>27where28A: SeqAccess<'de>,29{30visit_struct_seq(31&mut seq,32self.struct_info,33self.registration,34self.registry,35self.processor,36)37}3839fn visit_map<V>(self, mut map: V) -> Result<Self::Value, V::Error>40where41V: MapAccess<'de>,42{43visit_struct(44&mut map,45self.struct_info,46self.registration,47self.registry,48self.processor,49)50}51}525354