pub struct Deserializer<'de> { /* private fields */ }
Expand description
The RON deserializer.
If you just want to simply deserialize a value,
you can use the from_str
convenience function.
Implementations§
Source§impl<'de> Deserializer<'de>
impl<'de> Deserializer<'de>
Sourcepub fn from_str(input: &'de str) -> Result<Deserializer<'de>, SpannedError>
pub fn from_str(input: &'de str) -> Result<Deserializer<'de>, SpannedError>
Examples found in repository?
examples/reflection/reflection.rs (line 101)
56fn setup(type_registry: Res<AppTypeRegistry>) {
57 let mut value = Foo {
58 a: 1,
59 _ignored: NonReflectedValue { _a: 10 },
60 nested: Bar { b: 8 },
61 };
62
63 // You can set field values like this. The type must match exactly or this will fail.
64 *value.get_field_mut("a").unwrap() = 2usize;
65 assert_eq!(value.a, 2);
66 assert_eq!(*value.get_field::<usize>("a").unwrap(), 2);
67
68 // You can also get the `&dyn PartialReflect` value of a field like this
69 let field = value.field("a").unwrap();
70
71 // But values introspected via `PartialReflect` will not return `dyn Reflect` trait objects
72 // (even if the containing type does implement `Reflect`), so we need to convert them:
73 let fully_reflected_field = field.try_as_reflect().unwrap();
74
75 // Now, you can downcast your `Reflect` value like this:
76 assert_eq!(*fully_reflected_field.downcast_ref::<usize>().unwrap(), 2);
77
78 // For this specific case, we also support the shortcut `try_downcast_ref`:
79 assert_eq!(*field.try_downcast_ref::<usize>().unwrap(), 2);
80
81 // `DynamicStruct` also implements the `Struct` and `Reflect` traits.
82 let mut patch = DynamicStruct::default();
83 patch.insert("a", 4usize);
84
85 // You can "apply" Reflect implementations on top of other Reflect implementations.
86 // This will only set fields with the same name, and it will fail if the types don't match.
87 // You can use this to "patch" your types with new values.
88 value.apply(&patch);
89 assert_eq!(value.a, 4);
90
91 let type_registry = type_registry.read();
92 // By default, all derived `Reflect` types can be Serialized using serde. No need to derive
93 // Serialize!
94 let serializer = ReflectSerializer::new(&value, &type_registry);
95 let ron_string =
96 ron::ser::to_string_pretty(&serializer, ron::ser::PrettyConfig::default()).unwrap();
97 info!("{}\n", ron_string);
98
99 // Dynamic properties can be deserialized
100 let reflect_deserializer = ReflectDeserializer::new(&type_registry);
101 let mut deserializer = ron::de::Deserializer::from_str(&ron_string).unwrap();
102 let reflect_value = reflect_deserializer.deserialize(&mut deserializer).unwrap();
103
104 // Deserializing returns a `Box<dyn PartialReflect>` value.
105 // Generally, deserializing a value will return the "dynamic" variant of a type.
106 // For example, deserializing a struct will return the DynamicStruct type.
107 // "Opaque types" will be deserialized as themselves.
108 assert_eq!(
109 reflect_value.reflect_type_path(),
110 DynamicStruct::type_path(),
111 );
112
113 // Reflect has its own `partial_eq` implementation, named `reflect_partial_eq`. This behaves
114 // like normal `partial_eq`, but it treats "dynamic" and "non-dynamic" types the same. The
115 // `Foo` struct and deserialized `DynamicStruct` are considered equal for this reason:
116 assert!(reflect_value.reflect_partial_eq(&value).unwrap());
117
118 // By "patching" `Foo` with the deserialized DynamicStruct, we can "Deserialize" Foo.
119 // This means we can serialize and deserialize with a single `Reflect` derive!
120 value.apply(&*reflect_value);
121}
More examples
examples/reflection/dynamic_types.rs (line 77)
12fn main() {
13 #[derive(Reflect, Default, PartialEq, Debug)]
14 #[reflect(Identifiable, Default)]
15 struct Player {
16 id: u32,
17 }
18
19 #[reflect_trait]
20 trait Identifiable {
21 fn id(&self) -> u32;
22 }
23
24 impl Identifiable for Player {
25 fn id(&self) -> u32 {
26 self.id
27 }
28 }
29
30 // Normally, when instantiating a type, you get back exactly that type.
31 // This is because the type is known at compile time.
32 // We call this the "concrete" or "canonical" type.
33 let player: Player = Player { id: 123 };
34
35 // When working with reflected types, however, we often "erase" this type information
36 // using the `Reflect` trait object.
37 // This trait object also gives us access to all the methods in the `PartialReflect` trait too.
38 // The underlying type is still the same (in this case, `Player`),
39 // but now we've hidden that information from the compiler.
40 let reflected: Box<dyn Reflect> = Box::new(player);
41
42 // Because it's the same type under the hood, we can still downcast it back to the original type.
43 assert!(reflected.downcast_ref::<Player>().is_some());
44
45 // We can attempt to clone our value using `PartialReflect::reflect_clone`.
46 // This will recursively call `PartialReflect::reflect_clone` on all fields of the type.
47 // Or, if we had registered `ReflectClone` using `#[reflect(Clone)]`, it would simply call `Clone::clone` directly.
48 let cloned: Box<dyn Reflect> = reflected.reflect_clone().unwrap();
49 assert_eq!(cloned.downcast_ref::<Player>(), Some(&Player { id: 123 }));
50
51 // Another way we can "clone" our data is by converting it to a dynamic type.
52 // Notice here we bind it as a `dyn PartialReflect` instead of `dyn Reflect`.
53 // This is because it returns a dynamic type that simply represents the original type.
54 // In this case, because `Player` is a struct, it will return a `DynamicStruct`.
55 let dynamic: Box<dyn PartialReflect> = reflected.to_dynamic();
56 assert!(dynamic.is_dynamic());
57
58 // And if we try to convert it back to a `dyn Reflect` trait object, we'll get `None`.
59 // Dynamic types cannot be directly cast to `dyn Reflect` trait objects.
60 assert!(dynamic.try_as_reflect().is_none());
61
62 // Generally dynamic types are used to represent (or "proxy") the original type,
63 // so that we can continue to access its fields and overall structure.
64 let dynamic_ref = dynamic.reflect_ref().as_struct().unwrap();
65 let id = dynamic_ref.field("id").unwrap().try_downcast_ref::<u32>();
66 assert_eq!(id, Some(&123));
67
68 // It also enables us to create a representation of a type without having compile-time
69 // access to the actual type. This is how the reflection deserializers work.
70 // They generally can't know how to construct a type ahead of time,
71 // so they instead build and return these dynamic representations.
72 let input = "(id: 123)";
73 let mut registry = TypeRegistry::default();
74 registry.register::<Player>();
75 let registration = registry.get(std::any::TypeId::of::<Player>()).unwrap();
76 let deserialized = TypedReflectDeserializer::new(registration, ®istry)
77 .deserialize(&mut ron::Deserializer::from_str(input).unwrap())
78 .unwrap();
79
80 // Our deserialized output is a `DynamicStruct` that proxies/represents a `Player`.
81 assert!(deserialized.represents::<Player>());
82
83 // And while this does allow us to access the fields and structure of the type,
84 // there may be instances where we need the actual type.
85 // For example, if we want to convert our `dyn Reflect` into a `dyn Identifiable`,
86 // we can't use the `DynamicStruct` proxy.
87 let reflect_identifiable = registration
88 .data::<ReflectIdentifiable>()
89 .expect("`ReflectIdentifiable` should be registered");
90
91 // Trying to access the registry with our `deserialized` will give a compile error
92 // since it doesn't implement `Reflect`, only `PartialReflect`.
93 // Similarly, trying to force the operation will fail.
94 // This fails since the underlying type of `deserialized` is `DynamicStruct` and not `Player`.
95 assert!(deserialized
96 .try_as_reflect()
97 .and_then(|reflect_trait_obj| reflect_identifiable.get(reflect_trait_obj))
98 .is_none());
99
100 // So how can we go from a dynamic type to a concrete type?
101 // There are two ways:
102
103 // 1. Using `PartialReflect::apply`.
104 {
105 // If you know the type at compile time, you can construct a new value and apply the dynamic
106 // value to it.
107 let mut value = Player::default();
108 value.apply(deserialized.as_ref());
109 assert_eq!(value.id, 123);
110
111 // If you don't know the type at compile time, you need a dynamic way of constructing
112 // an instance of the type. One such way is to use the `ReflectDefault` type data.
113 let reflect_default = registration
114 .data::<ReflectDefault>()
115 .expect("`ReflectDefault` should be registered");
116
117 let mut value: Box<dyn Reflect> = reflect_default.default();
118 value.apply(deserialized.as_ref());
119
120 let identifiable: &dyn Identifiable = reflect_identifiable.get(value.as_reflect()).unwrap();
121 assert_eq!(identifiable.id(), 123);
122 }
123
124 // 2. Using `FromReflect`
125 {
126 // If you know the type at compile time, you can use the `FromReflect` trait to convert the
127 // dynamic value into the concrete type directly.
128 let value: Player = Player::from_reflect(deserialized.as_ref()).unwrap();
129 assert_eq!(value.id, 123);
130
131 // If you don't know the type at compile time, you can use the `ReflectFromReflect` type data
132 // to perform the conversion dynamically.
133 let reflect_from_reflect = registration
134 .data::<ReflectFromReflect>()
135 .expect("`ReflectFromReflect` should be registered");
136
137 let value: Box<dyn Reflect> = reflect_from_reflect
138 .from_reflect(deserialized.as_ref())
139 .unwrap();
140 let identifiable: &dyn Identifiable = reflect_identifiable.get(value.as_reflect()).unwrap();
141 assert_eq!(identifiable.id(), 123);
142 }
143
144 // Lastly, while dynamic types are commonly generated via reflection methods like
145 // `PartialReflect::to_dynamic` or via the reflection deserializers,
146 // you can also construct them manually.
147 let mut my_dynamic_list = DynamicList::from_iter([1u32, 2u32, 3u32]);
148
149 // This is useful when you just need to apply some subset of changes to a type.
150 let mut my_list: Vec<u32> = Vec::new();
151 my_list.apply(&my_dynamic_list);
152 assert_eq!(my_list, vec![1, 2, 3]);
153
154 // And if you want it to actually proxy a type, you can configure it to do that as well:
155 assert!(!my_dynamic_list
156 .as_partial_reflect()
157 .represents::<Vec<u32>>());
158 my_dynamic_list.set_represented_type(Some(<Vec<u32>>::type_info()));
159 assert!(my_dynamic_list
160 .as_partial_reflect()
161 .represents::<Vec<u32>>());
162
163 // ============================= REFERENCE ============================= //
164 // For reference, here are all the available dynamic types:
165
166 // 1. `DynamicTuple`
167 {
168 let mut dynamic_tuple = DynamicTuple::default();
169 dynamic_tuple.insert(1u32);
170 dynamic_tuple.insert(2u32);
171 dynamic_tuple.insert(3u32);
172
173 let mut my_tuple: (u32, u32, u32) = (0, 0, 0);
174 my_tuple.apply(&dynamic_tuple);
175 assert_eq!(my_tuple, (1, 2, 3));
176 }
177
178 // 2. `DynamicArray`
179 {
180 let dynamic_array = DynamicArray::from_iter([1u32, 2u32, 3u32]);
181
182 let mut my_array = [0u32; 3];
183 my_array.apply(&dynamic_array);
184 assert_eq!(my_array, [1, 2, 3]);
185 }
186
187 // 3. `DynamicList`
188 {
189 let dynamic_list = DynamicList::from_iter([1u32, 2u32, 3u32]);
190
191 let mut my_list: Vec<u32> = Vec::new();
192 my_list.apply(&dynamic_list);
193 assert_eq!(my_list, vec![1, 2, 3]);
194 }
195
196 // 4. `DynamicSet`
197 {
198 let mut dynamic_set = DynamicSet::from_iter(["x", "y", "z"]);
199 assert!(dynamic_set.contains(&"x"));
200
201 dynamic_set.remove(&"y");
202
203 let mut my_set: HashSet<&str> = HashSet::default();
204 my_set.apply(&dynamic_set);
205 assert_eq!(my_set, HashSet::from_iter(["x", "z"]));
206 }
207
208 // 5. `DynamicMap`
209 {
210 let dynamic_map = DynamicMap::from_iter([("x", 1u32), ("y", 2u32), ("z", 3u32)]);
211
212 let mut my_map: HashMap<&str, u32> = HashMap::default();
213 my_map.apply(&dynamic_map);
214 assert_eq!(my_map.get("x"), Some(&1));
215 assert_eq!(my_map.get("y"), Some(&2));
216 assert_eq!(my_map.get("z"), Some(&3));
217 }
218
219 // 6. `DynamicStruct`
220 {
221 #[derive(Reflect, Default, Debug, PartialEq)]
222 struct MyStruct {
223 x: u32,
224 y: u32,
225 z: u32,
226 }
227
228 let mut dynamic_struct = DynamicStruct::default();
229 dynamic_struct.insert("x", 1u32);
230 dynamic_struct.insert("y", 2u32);
231 dynamic_struct.insert("z", 3u32);
232
233 let mut my_struct = MyStruct::default();
234 my_struct.apply(&dynamic_struct);
235 assert_eq!(my_struct, MyStruct { x: 1, y: 2, z: 3 });
236 }
237
238 // 7. `DynamicTupleStruct`
239 {
240 #[derive(Reflect, Default, Debug, PartialEq)]
241 struct MyTupleStruct(u32, u32, u32);
242
243 let mut dynamic_tuple_struct = DynamicTupleStruct::default();
244 dynamic_tuple_struct.insert(1u32);
245 dynamic_tuple_struct.insert(2u32);
246 dynamic_tuple_struct.insert(3u32);
247
248 let mut my_tuple_struct = MyTupleStruct::default();
249 my_tuple_struct.apply(&dynamic_tuple_struct);
250 assert_eq!(my_tuple_struct, MyTupleStruct(1, 2, 3));
251 }
252
253 // 8. `DynamicEnum`
254 {
255 #[derive(Reflect, Default, Debug, PartialEq)]
256 enum MyEnum {
257 #[default]
258 Empty,
259 Xyz(u32, u32, u32),
260 }
261
262 let mut values = DynamicTuple::default();
263 values.insert(1u32);
264 values.insert(2u32);
265 values.insert(3u32);
266
267 let dynamic_variant = DynamicVariant::Tuple(values);
268 let dynamic_enum = DynamicEnum::new("Xyz", dynamic_variant);
269
270 let mut my_enum = MyEnum::default();
271 my_enum.apply(&dynamic_enum);
272 assert_eq!(my_enum, MyEnum::Xyz(1, 2, 3));
273 }
274}
pub fn from_bytes(input: &'de [u8]) -> Result<Deserializer<'de>, SpannedError>
pub fn from_str_with_options( input: &'de str, options: Options, ) -> Result<Deserializer<'de>, SpannedError>
pub fn from_bytes_with_options( input: &'de [u8], options: Options, ) -> Result<Deserializer<'de>, SpannedError>
pub fn remainder(&self) -> Cow<'_, str>
pub fn span_error(&self, code: Error) -> SpannedError
Trait Implementations§
Source§impl<'de, 'a> Deserializer<'de> for &'a mut Deserializer<'de>
impl<'de, 'a> Deserializer<'de> for &'a mut Deserializer<'de>
Source§type Error = Error
type Error = Error
The error type that can be returned if some error occurs during
deserialization.
Source§fn deserialize_any<V>(
self,
visitor: V,
) -> Result<<V as Visitor<'de>>::Value, Error>where
V: Visitor<'de>,
fn deserialize_any<V>(
self,
visitor: V,
) -> Result<<V as Visitor<'de>>::Value, Error>where
V: Visitor<'de>,
Require the
Deserializer
to figure out how to drive the visitor based
on what data type is in the input. Read moreSource§fn deserialize_bool<V>(
self,
visitor: V,
) -> Result<<V as Visitor<'de>>::Value, Error>where
V: Visitor<'de>,
fn deserialize_bool<V>(
self,
visitor: V,
) -> Result<<V as Visitor<'de>>::Value, Error>where
V: Visitor<'de>,
Hint that the
Deserialize
type is expecting a bool
value.Source§fn deserialize_i8<V>(
self,
visitor: V,
) -> Result<<V as Visitor<'de>>::Value, Error>where
V: Visitor<'de>,
fn deserialize_i8<V>(
self,
visitor: V,
) -> Result<<V as Visitor<'de>>::Value, Error>where
V: Visitor<'de>,
Hint that the
Deserialize
type is expecting an i8
value.Source§fn deserialize_i16<V>(
self,
visitor: V,
) -> Result<<V as Visitor<'de>>::Value, Error>where
V: Visitor<'de>,
fn deserialize_i16<V>(
self,
visitor: V,
) -> Result<<V as Visitor<'de>>::Value, Error>where
V: Visitor<'de>,
Hint that the
Deserialize
type is expecting an i16
value.Source§fn deserialize_i32<V>(
self,
visitor: V,
) -> Result<<V as Visitor<'de>>::Value, Error>where
V: Visitor<'de>,
fn deserialize_i32<V>(
self,
visitor: V,
) -> Result<<V as Visitor<'de>>::Value, Error>where
V: Visitor<'de>,
Hint that the
Deserialize
type is expecting an i32
value.Source§fn deserialize_i64<V>(
self,
visitor: V,
) -> Result<<V as Visitor<'de>>::Value, Error>where
V: Visitor<'de>,
fn deserialize_i64<V>(
self,
visitor: V,
) -> Result<<V as Visitor<'de>>::Value, Error>where
V: Visitor<'de>,
Hint that the
Deserialize
type is expecting an i64
value.Source§fn deserialize_u8<V>(
self,
visitor: V,
) -> Result<<V as Visitor<'de>>::Value, Error>where
V: Visitor<'de>,
fn deserialize_u8<V>(
self,
visitor: V,
) -> Result<<V as Visitor<'de>>::Value, Error>where
V: Visitor<'de>,
Hint that the
Deserialize
type is expecting a u8
value.Source§fn deserialize_u16<V>(
self,
visitor: V,
) -> Result<<V as Visitor<'de>>::Value, Error>where
V: Visitor<'de>,
fn deserialize_u16<V>(
self,
visitor: V,
) -> Result<<V as Visitor<'de>>::Value, Error>where
V: Visitor<'de>,
Hint that the
Deserialize
type is expecting a u16
value.Source§fn deserialize_u32<V>(
self,
visitor: V,
) -> Result<<V as Visitor<'de>>::Value, Error>where
V: Visitor<'de>,
fn deserialize_u32<V>(
self,
visitor: V,
) -> Result<<V as Visitor<'de>>::Value, Error>where
V: Visitor<'de>,
Hint that the
Deserialize
type is expecting a u32
value.Source§fn deserialize_u64<V>(
self,
visitor: V,
) -> Result<<V as Visitor<'de>>::Value, Error>where
V: Visitor<'de>,
fn deserialize_u64<V>(
self,
visitor: V,
) -> Result<<V as Visitor<'de>>::Value, Error>where
V: Visitor<'de>,
Hint that the
Deserialize
type is expecting a u64
value.Source§fn deserialize_f32<V>(
self,
visitor: V,
) -> Result<<V as Visitor<'de>>::Value, Error>where
V: Visitor<'de>,
fn deserialize_f32<V>(
self,
visitor: V,
) -> Result<<V as Visitor<'de>>::Value, Error>where
V: Visitor<'de>,
Hint that the
Deserialize
type is expecting a f32
value.Source§fn deserialize_f64<V>(
self,
visitor: V,
) -> Result<<V as Visitor<'de>>::Value, Error>where
V: Visitor<'de>,
fn deserialize_f64<V>(
self,
visitor: V,
) -> Result<<V as Visitor<'de>>::Value, Error>where
V: Visitor<'de>,
Hint that the
Deserialize
type is expecting a f64
value.Source§fn deserialize_char<V>(
self,
visitor: V,
) -> Result<<V as Visitor<'de>>::Value, Error>where
V: Visitor<'de>,
fn deserialize_char<V>(
self,
visitor: V,
) -> Result<<V as Visitor<'de>>::Value, Error>where
V: Visitor<'de>,
Hint that the
Deserialize
type is expecting a char
value.Source§fn deserialize_str<V>(
self,
visitor: V,
) -> Result<<V as Visitor<'de>>::Value, Error>where
V: Visitor<'de>,
fn deserialize_str<V>(
self,
visitor: V,
) -> Result<<V as Visitor<'de>>::Value, Error>where
V: Visitor<'de>,
Hint that the
Deserialize
type is expecting a string value and does
not benefit from taking ownership of buffered data owned by the
Deserializer
. Read moreSource§fn deserialize_string<V>(
self,
visitor: V,
) -> Result<<V as Visitor<'de>>::Value, Error>where
V: Visitor<'de>,
fn deserialize_string<V>(
self,
visitor: V,
) -> Result<<V as Visitor<'de>>::Value, Error>where
V: Visitor<'de>,
Hint that the
Deserialize
type is expecting a string value and would
benefit from taking ownership of buffered data owned by the
Deserializer
. Read moreSource§fn deserialize_bytes<V>(
self,
visitor: V,
) -> Result<<V as Visitor<'de>>::Value, Error>where
V: Visitor<'de>,
fn deserialize_bytes<V>(
self,
visitor: V,
) -> Result<<V as Visitor<'de>>::Value, Error>where
V: Visitor<'de>,
Hint that the
Deserialize
type is expecting a byte array and does not
benefit from taking ownership of buffered data owned by the
Deserializer
. Read moreSource§fn deserialize_byte_buf<V>(
self,
visitor: V,
) -> Result<<V as Visitor<'de>>::Value, Error>where
V: Visitor<'de>,
fn deserialize_byte_buf<V>(
self,
visitor: V,
) -> Result<<V as Visitor<'de>>::Value, Error>where
V: Visitor<'de>,
Hint that the
Deserialize
type is expecting a byte array and would
benefit from taking ownership of buffered data owned by the
Deserializer
. Read moreSource§fn deserialize_option<V>(
self,
visitor: V,
) -> Result<<V as Visitor<'de>>::Value, Error>where
V: Visitor<'de>,
fn deserialize_option<V>(
self,
visitor: V,
) -> Result<<V as Visitor<'de>>::Value, Error>where
V: Visitor<'de>,
Hint that the
Deserialize
type is expecting an optional value. Read moreSource§fn deserialize_unit<V>(
self,
visitor: V,
) -> Result<<V as Visitor<'de>>::Value, Error>where
V: Visitor<'de>,
fn deserialize_unit<V>(
self,
visitor: V,
) -> Result<<V as Visitor<'de>>::Value, Error>where
V: Visitor<'de>,
Hint that the
Deserialize
type is expecting a unit value.Source§fn deserialize_unit_struct<V>(
self,
name: &'static str,
visitor: V,
) -> Result<<V as Visitor<'de>>::Value, Error>where
V: Visitor<'de>,
fn deserialize_unit_struct<V>(
self,
name: &'static str,
visitor: V,
) -> Result<<V as Visitor<'de>>::Value, Error>where
V: Visitor<'de>,
Hint that the
Deserialize
type is expecting a unit struct with a
particular name.Source§fn deserialize_newtype_struct<V>(
self,
name: &'static str,
visitor: V,
) -> Result<<V as Visitor<'de>>::Value, Error>where
V: Visitor<'de>,
fn deserialize_newtype_struct<V>(
self,
name: &'static str,
visitor: V,
) -> Result<<V as Visitor<'de>>::Value, Error>where
V: Visitor<'de>,
Hint that the
Deserialize
type is expecting a newtype struct with a
particular name.Source§fn deserialize_seq<V>(
self,
visitor: V,
) -> Result<<V as Visitor<'de>>::Value, Error>where
V: Visitor<'de>,
fn deserialize_seq<V>(
self,
visitor: V,
) -> Result<<V as Visitor<'de>>::Value, Error>where
V: Visitor<'de>,
Hint that the
Deserialize
type is expecting a sequence of values.Source§fn deserialize_tuple<V>(
self,
_len: usize,
visitor: V,
) -> Result<<V as Visitor<'de>>::Value, Error>where
V: Visitor<'de>,
fn deserialize_tuple<V>(
self,
_len: usize,
visitor: V,
) -> Result<<V as Visitor<'de>>::Value, Error>where
V: Visitor<'de>,
Hint that the
Deserialize
type is expecting a sequence of values and
knows how many values there are without looking at the serialized data.Source§fn deserialize_tuple_struct<V>(
self,
name: &'static str,
len: usize,
visitor: V,
) -> Result<<V as Visitor<'de>>::Value, Error>where
V: Visitor<'de>,
fn deserialize_tuple_struct<V>(
self,
name: &'static str,
len: usize,
visitor: V,
) -> Result<<V as Visitor<'de>>::Value, Error>where
V: Visitor<'de>,
Hint that the
Deserialize
type is expecting a tuple struct with a
particular name and number of fields.Source§fn deserialize_map<V>(
self,
visitor: V,
) -> Result<<V as Visitor<'de>>::Value, Error>where
V: Visitor<'de>,
fn deserialize_map<V>(
self,
visitor: V,
) -> Result<<V as Visitor<'de>>::Value, Error>where
V: Visitor<'de>,
Hint that the
Deserialize
type is expecting a map of key-value pairs.Source§fn deserialize_struct<V>(
self,
name: &'static str,
_fields: &'static [&'static str],
visitor: V,
) -> Result<<V as Visitor<'de>>::Value, Error>where
V: Visitor<'de>,
fn deserialize_struct<V>(
self,
name: &'static str,
_fields: &'static [&'static str],
visitor: V,
) -> Result<<V as Visitor<'de>>::Value, Error>where
V: Visitor<'de>,
Hint that the
Deserialize
type is expecting a struct with a particular
name and fields.Source§fn deserialize_enum<V>(
self,
name: &'static str,
_variants: &'static [&'static str],
visitor: V,
) -> Result<<V as Visitor<'de>>::Value, Error>where
V: Visitor<'de>,
fn deserialize_enum<V>(
self,
name: &'static str,
_variants: &'static [&'static str],
visitor: V,
) -> Result<<V as Visitor<'de>>::Value, Error>where
V: Visitor<'de>,
Hint that the
Deserialize
type is expecting an enum value with a
particular name and possible variants.Source§fn deserialize_identifier<V>(
self,
visitor: V,
) -> Result<<V as Visitor<'de>>::Value, Error>where
V: Visitor<'de>,
fn deserialize_identifier<V>(
self,
visitor: V,
) -> Result<<V as Visitor<'de>>::Value, Error>where
V: Visitor<'de>,
Hint that the
Deserialize
type is expecting the name of a struct
field or the discriminant of an enum variant.Source§fn deserialize_ignored_any<V>(
self,
visitor: V,
) -> Result<<V as Visitor<'de>>::Value, Error>where
V: Visitor<'de>,
fn deserialize_ignored_any<V>(
self,
visitor: V,
) -> Result<<V as Visitor<'de>>::Value, Error>where
V: Visitor<'de>,
Hint that the
Deserialize
type needs to deserialize a value whose type
doesn’t matter because it is ignored. Read moreSource§fn deserialize_i128<V>(
self,
visitor: V,
) -> Result<<V as Visitor<'de>>::Value, Self::Error>where
V: Visitor<'de>,
fn deserialize_i128<V>(
self,
visitor: V,
) -> Result<<V as Visitor<'de>>::Value, Self::Error>where
V: Visitor<'de>,
Source§fn deserialize_u128<V>(
self,
visitor: V,
) -> Result<<V as Visitor<'de>>::Value, Self::Error>where
V: Visitor<'de>,
fn deserialize_u128<V>(
self,
visitor: V,
) -> Result<<V as Visitor<'de>>::Value, Self::Error>where
V: Visitor<'de>,
Source§fn is_human_readable(&self) -> bool
fn is_human_readable(&self) -> bool
Determine whether
Deserialize
implementations should expect to
deserialize their human-readable form. Read moreAuto Trait Implementations§
impl<'de> Freeze for Deserializer<'de>
impl<'de> RefUnwindSafe for Deserializer<'de>
impl<'de> Send for Deserializer<'de>
impl<'de> Sync for Deserializer<'de>
impl<'de> Unpin for Deserializer<'de>
impl<'de> UnwindSafe for Deserializer<'de>
Blanket Implementations§
Source§impl<T, U> AsBindGroupShaderType<U> for T
impl<T, U> AsBindGroupShaderType<U> for T
Source§fn as_bind_group_shader_type(&self, _images: &RenderAssets<GpuImage>) -> U
fn as_bind_group_shader_type(&self, _images: &RenderAssets<GpuImage>) -> U
Return the
T
ShaderType
for self
. When used in AsBindGroup
derives, it is safe to assume that all images in self
exist.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
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Converts
Box<dyn Trait>
(where Trait: Downcast
) to Box<dyn Any>
, which can then be
downcast
into Box<dyn ConcreteType>
where ConcreteType
implements Trait
.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Converts
Rc<Trait>
(where Trait: Downcast
) to Rc<Any>
, which can then be further
downcast
into Rc<ConcreteType>
where ConcreteType
implements Trait
.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
Converts
&Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &Any
’s vtable from &Trait
’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
Converts
&mut Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &mut Any
’s vtable from &mut Trait
’s.Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Convert
Box<dyn Trait>
(where Trait: Downcast
) to Box<dyn Any>
. Box<dyn Any>
can
then be further downcast
into Box<ConcreteType>
where ConcreteType
implements Trait
.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Convert
Rc<Trait>
(where Trait: Downcast
) to Rc<Any>
. Rc<Any>
can then be
further downcast
into Rc<ConcreteType>
where ConcreteType
implements Trait
.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
Convert
&Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &Any
’s vtable from &Trait
’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
Convert
&mut Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &mut Any
’s vtable from &mut Trait
’s.Source§impl<T> DowncastSend for T
impl<T> DowncastSend for T
Source§impl<T> DowncastSync for T
impl<T> DowncastSync for T
Source§impl<T> FmtForward for T
impl<T> FmtForward for T
Source§fn fmt_binary(self) -> FmtBinary<Self>where
Self: Binary,
fn fmt_binary(self) -> FmtBinary<Self>where
Self: Binary,
Causes
self
to use its Binary
implementation when Debug
-formatted.Source§fn fmt_display(self) -> FmtDisplay<Self>where
Self: Display,
fn fmt_display(self) -> FmtDisplay<Self>where
Self: Display,
Causes
self
to use its Display
implementation when
Debug
-formatted.Source§fn fmt_lower_exp(self) -> FmtLowerExp<Self>where
Self: LowerExp,
fn fmt_lower_exp(self) -> FmtLowerExp<Self>where
Self: LowerExp,
Causes
self
to use its LowerExp
implementation when
Debug
-formatted.Source§fn fmt_lower_hex(self) -> FmtLowerHex<Self>where
Self: LowerHex,
fn fmt_lower_hex(self) -> FmtLowerHex<Self>where
Self: LowerHex,
Causes
self
to use its LowerHex
implementation when
Debug
-formatted.Source§fn fmt_octal(self) -> FmtOctal<Self>where
Self: Octal,
fn fmt_octal(self) -> FmtOctal<Self>where
Self: Octal,
Causes
self
to use its Octal
implementation when Debug
-formatted.Source§fn fmt_pointer(self) -> FmtPointer<Self>where
Self: Pointer,
fn fmt_pointer(self) -> FmtPointer<Self>where
Self: Pointer,
Causes
self
to use its Pointer
implementation when
Debug
-formatted.Source§fn fmt_upper_exp(self) -> FmtUpperExp<Self>where
Self: UpperExp,
fn fmt_upper_exp(self) -> FmtUpperExp<Self>where
Self: UpperExp,
Causes
self
to use its UpperExp
implementation when
Debug
-formatted.Source§fn fmt_upper_hex(self) -> FmtUpperHex<Self>where
Self: UpperHex,
fn fmt_upper_hex(self) -> FmtUpperHex<Self>where
Self: UpperHex,
Causes
self
to use its UpperHex
implementation when
Debug
-formatted.Source§impl<S> FromSample<S> for S
impl<S> FromSample<S> for S
fn from_sample_(s: S) -> S
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 moreSource§impl<F, T> IntoSample<T> for Fwhere
T: FromSample<F>,
impl<F, T> IntoSample<T> for Fwhere
T: FromSample<F>,
fn into_sample(self) -> T
Source§impl<T> Pipe for Twhere
T: ?Sized,
impl<T> Pipe for Twhere
T: ?Sized,
Source§fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
Pipes by value. This is generally the method you want to use. Read more
Source§fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
Borrows
self
and passes that borrow into the pipe function. Read moreSource§fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
Mutably borrows
self
and passes that borrow into the pipe function. Read moreSource§fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
Source§fn pipe_borrow_mut<'a, B, R>(
&'a mut self,
func: impl FnOnce(&'a mut B) -> R,
) -> R
fn pipe_borrow_mut<'a, B, R>( &'a mut self, func: impl FnOnce(&'a mut B) -> R, ) -> R
Source§fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
Borrows
self
, then passes self.as_ref()
into the pipe function.Source§fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
Mutably borrows
self
, then passes self.as_mut()
into the pipe
function.Source§fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
Borrows
self
, then passes self.deref()
into the pipe function.Source§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<T> Tap for T
impl<T> Tap for T
Source§fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
Immutable access to the
Borrow<B>
of a value. Read moreSource§fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
Mutable access to the
BorrowMut<B>
of a value. Read moreSource§fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
Immutable access to the
AsRef<R>
view of a value. Read moreSource§fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
Mutable access to the
AsMut<R>
view of a value. Read moreSource§fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
Immutable access to the
Deref::Target
of a value. Read moreSource§fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
Mutable access to the
Deref::Target
of a value. Read moreSource§fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
Calls
.tap()
only in debug builds, and is erased in release builds.Source§fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
Calls
.tap_mut()
only in debug builds, and is erased in release
builds.Source§fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
Calls
.tap_borrow()
only in debug builds, and is erased in release
builds.Source§fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
Calls
.tap_borrow_mut()
only in debug builds, and is erased in release
builds.Source§fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
Calls
.tap_ref()
only in debug builds, and is erased in release
builds.Source§fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
Calls
.tap_ref_mut()
only in debug builds, and is erased in release
builds.Source§fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
Calls
.tap_deref()
only in debug builds, and is erased in release
builds.