Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
9d59375
Add ReflectDeserializerProcessor
aecsocket Sep 27, 2024
8f5cd7b
fix clippy
aecsocket Sep 27, 2024
6749256
improve docs
aecsocket Sep 27, 2024
38e618f
address comments
aecsocket Sep 28, 2024
c8a3980
ReflectDeserializerProcessor `should_deserialize` returns the actual …
aecsocket Sep 29, 2024
5e6d02c
wip: switch to type param for reflect deserializer processor
aecsocket Sep 29, 2024
19bd7d8
fix processor
aecsocket Sep 29, 2024
56dbf02
get it working with the type system
aecsocket Sep 30, 2024
4a4993e
fix docs for deserialize processor
aecsocket Sep 30, 2024
2c983cc
fix doc tests
aecsocket Sep 30, 2024
1d5f725
Add default `P = ()` for ReflectDeserializer
aecsocket Sep 30, 2024
283bc15
add P = () to TypedReflectDeserializer as well
aecsocket Sep 30, 2024
4a4ddaf
Use `new_internal` in reflect deserializer
aecsocket Sep 30, 2024
7b534db
Provide access to TypeRegistry from processor
aecsocket Sep 30, 2024
06e1a65
doc fix
aecsocket Sep 30, 2024
428bfa2
fix doc tests
aecsocket Sep 30, 2024
c9168b6
Update for main
aecsocket Oct 4, 2024
bb1bc39
Address review comments
aecsocket Oct 4, 2024
fa1f55a
more docs and test for returning Box of wrong type
aecsocket Oct 4, 2024
e689f6b
clippy
aecsocket Oct 4, 2024
066d722
fix docs
aecsocket Oct 5, 2024
63dae42
wip: image pipeline example
aecsocket Oct 5, 2024
56c7e17
working logic
aecsocket Oct 5, 2024
e76e63d
Update examples/README.md
aecsocket Oct 5, 2024
18069a9
Add nicer image asset for image processor example
aecsocket Oct 5, 2024
9e447be
fix up rebase
aecsocket Oct 12, 2024
27a3183
further fix up rebase
aecsocket Oct 12, 2024
b00d98d
remove `as_ref`s
aecsocket Oct 16, 2024
7a652af
add more processor docs
aecsocket Oct 16, 2024
aa0d89b
remove example
aecsocket Oct 16, 2024
7faf965
switch to incorrect spelling
aecsocket Oct 29, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 9 additions & 14 deletions crates/bevy_reflect/src/serde/de/arrays.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,31 +5,25 @@ use crate::{
use core::{fmt, fmt::Formatter};
use serde::de::{Error, SeqAccess, Visitor};

use super::ReflectDeserializerProcessor;

/// A [`Visitor`] for deserializing [`Array`] values.
///
/// [`Array`]: crate::Array
pub(super) struct ArrayVisitor<'a> {
array_info: &'static ArrayInfo,
registry: &'a TypeRegistry,
}

impl<'a> ArrayVisitor<'a> {
pub fn new(array_info: &'static ArrayInfo, registry: &'a TypeRegistry) -> Self {
Self {
array_info,
registry,
}
}
pub(super) struct ArrayVisitor<'a, P> {
pub array_info: &'static ArrayInfo,
pub registry: &'a TypeRegistry,
pub processor: Option<&'a mut P>,
}

impl<'a, 'de> Visitor<'de> for ArrayVisitor<'a> {
impl<'de, P: ReflectDeserializerProcessor> Visitor<'de> for ArrayVisitor<'_, P> {
type Value = DynamicArray;

fn expecting(&self, formatter: &mut Formatter) -> fmt::Result {
formatter.write_str("reflected array value")
}

fn visit_seq<V>(self, mut seq: V) -> Result<Self::Value, V::Error>
fn visit_seq<V>(mut self, mut seq: V) -> Result<Self::Value, V::Error>
where
V: SeqAccess<'de>,
{
Expand All @@ -38,6 +32,7 @@ impl<'a, 'de> Visitor<'de> for ArrayVisitor<'a> {
while let Some(value) = seq.next_element_seed(TypedReflectDeserializer::new_internal(
registration,
self.registry,
self.processor.as_deref_mut(),
))? {
vec.push(value);
}
Expand Down
Loading