Skip to content

Commit 535618b

Browse files
committed
Rename struct MapAccess to ElementMapAccess, because the old name can be confused with serde trait
1 parent 9cb2a2e commit 535618b

File tree

2 files changed

+20
-19
lines changed

2 files changed

+20
-19
lines changed

src/de/map.rs

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,13 @@ use crate::{
1212
name::QName,
1313
};
1414
use serde::de::value::BorrowedStrDeserializer;
15-
use serde::de::{self, DeserializeSeed, SeqAccess, Visitor};
15+
use serde::de::{self, DeserializeSeed, MapAccess, SeqAccess, Visitor};
1616
use serde::serde_if_integer128;
1717
use std::borrow::Cow;
1818
use std::ops::Range;
1919

2020
/// Defines a source that should be used to deserialize a value in the next call
21-
/// to [`next_value_seed()`](de::MapAccess::next_value_seed)
21+
/// to [`next_value_seed()`](MapAccess::next_value_seed)
2222
#[derive(Debug, PartialEq)]
2323
enum ValueSource {
2424
/// Source are not specified, because [`next_key_seed()`] not yet called.
@@ -28,8 +28,8 @@ enum ValueSource {
2828
/// Attempt to call [`next_value_seed()`] while accessor in this state would
2929
/// return a [`DeError::KeyNotRead`] error.
3030
///
31-
/// [`next_key_seed()`]: de::MapAccess::next_key_seed
32-
/// [`next_value_seed()`]: de::MapAccess::next_value_seed
31+
/// [`next_key_seed()`]: MapAccess::next_key_seed
32+
/// [`next_value_seed()`]: MapAccess::next_value_seed
3333
Unknown,
3434
/// Next value should be deserialized from an attribute value; value is located
3535
/// at specified span.
@@ -62,7 +62,7 @@ enum ValueSource {
6262
/// When in this state, next event, returned by [`next()`], will be a [`Start`],
6363
/// which represents both a key, and a value. Value would be deserialized from
6464
/// the whole element and how is will be done determined by the value deserializer.
65-
/// The [`MapAccess`] do not consume any events in that state.
65+
/// The [`ElementMapAccess`] do not consume any events in that state.
6666
///
6767
/// Because in that state any encountered `<tag>` is mapped to the [`VALUE_KEY`]
6868
/// field, it is possible to use tag name as an enum discriminator, so `enum`s
@@ -105,7 +105,7 @@ enum ValueSource {
105105
/// [`next()`]: Deserializer::next()
106106
/// [`name()`]: BytesStart::name()
107107
/// [`Text`]: Self::Text
108-
/// [list of known fields]: MapAccess::fields
108+
/// [list of known fields]: ElementMapAccess::fields
109109
Content,
110110
/// Next value should be deserialized from an element with a dedicated name.
111111
/// If deserialized type is a sequence, then that sequence will collect all
@@ -118,7 +118,7 @@ enum ValueSource {
118118
/// When in this state, next event, returned by [`next()`], will be a [`Start`],
119119
/// which represents both a key, and a value. Value would be deserialized from
120120
/// the whole element and how is will be done determined by the value deserializer.
121-
/// The [`MapAccess`] do not consume any events in that state.
121+
/// The [`ElementMapAccess`] do not consume any events in that state.
122122
///
123123
/// An illustration below shows, what data is used to deserialize key and value:
124124
/// ```xml
@@ -166,7 +166,7 @@ enum ValueSource {
166166
///
167167
/// - `'a` lifetime represents a parent deserializer, which could own the data
168168
/// buffer.
169-
pub(crate) struct MapAccess<'de, 'a, R, E>
169+
pub(crate) struct ElementMapAccess<'de, 'a, R, E>
170170
where
171171
R: XmlRead<'de>,
172172
E: EntityResolver,
@@ -192,18 +192,18 @@ where
192192
has_value_field: bool,
193193
}
194194

195-
impl<'de, 'a, R, E> MapAccess<'de, 'a, R, E>
195+
impl<'de, 'a, R, E> ElementMapAccess<'de, 'a, R, E>
196196
where
197197
R: XmlRead<'de>,
198198
E: EntityResolver,
199199
{
200-
/// Create a new MapAccess
200+
/// Create a new ElementMapAccess
201201
pub fn new(
202202
de: &'a mut Deserializer<'de, R, E>,
203203
start: BytesStart<'de>,
204204
fields: &'static [&'static str],
205205
) -> Result<Self, DeError> {
206-
Ok(MapAccess {
206+
Ok(Self {
207207
de,
208208
iter: IterState::new(start.name().as_ref().len(), false),
209209
start,
@@ -214,7 +214,7 @@ where
214214
}
215215
}
216216

217-
impl<'de, 'a, R, E> de::MapAccess<'de> for MapAccess<'de, 'a, R, E>
217+
impl<'de, 'a, R, E> MapAccess<'de> for ElementMapAccess<'de, 'a, R, E>
218218
where
219219
R: XmlRead<'de>,
220220
E: EntityResolver,
@@ -403,7 +403,7 @@ macro_rules! forward {
403403
/// with the same deserializer;
404404
/// - sequences, tuples and tuple structs are deserialized by iterating within the
405405
/// parent tag and deserializing each tag or text content using [`SeqItemDeserializer`];
406-
/// - structs and maps are deserialized using new instance of [`MapAccess`];
406+
/// - structs and maps are deserialized using new instance of [`ElementMapAccess`];
407407
/// - enums:
408408
/// - in case of [`DeEvent::Text`] event the text content is deserialized as
409409
/// a `$text` variant. Enum content is deserialized from the text using
@@ -426,7 +426,7 @@ where
426426
{
427427
/// Access to the map that created this deserializer. Gives access to the
428428
/// context, such as list of fields, that current map known about.
429-
map: &'m mut MapAccess<'de, 'a, R, E>,
429+
map: &'m mut ElementMapAccess<'de, 'a, R, E>,
430430
/// Determines, should [`Deserializer::read_string_impl()`] expand the second
431431
/// level of tags or not.
432432
///
@@ -585,7 +585,7 @@ where
585585
// Clone is cheap if event borrows from the input
586586
DeEvent::Start(e) => TagFilter::Include(e.clone()),
587587
// SAFETY: we use that deserializer with `allow_start == true`
588-
// only from the `MapAccess::next_value_seed` and only when we
588+
// only from the `ElementMapAccess::next_value_seed` and only when we
589589
// peeked `Start` event
590590
_ => unreachable!(),
591591
}
@@ -698,7 +698,7 @@ where
698698
{
699699
/// Accessor to a map that creates this accessor and to a deserializer for
700700
/// a sequence items.
701-
map: &'m mut MapAccess<'de, 'a, R, E>,
701+
map: &'m mut ElementMapAccess<'de, 'a, R, E>,
702702
/// Filter that determines whether a tag is a part of this sequence.
703703
///
704704
/// When feature [`overlapped-lists`] is not activated, iteration will stop
@@ -808,7 +808,7 @@ where
808808
/// contains something else other than text, an error is returned, but if it
809809
/// contains a text and something else (for example, `<item>text<tag/></item>`),
810810
/// then the trail is just ignored;
811-
/// - structs and maps are deserialized using new [`MapAccess`];
811+
/// - structs and maps are deserialized using new [`ElementMapAccess`];
812812
/// - enums:
813813
/// - in case of [`DeEvent::Text`] event the text content is deserialized as
814814
/// a `$text` variant. Enum content is deserialized from the text using
@@ -831,7 +831,7 @@ where
831831
{
832832
/// Access to the map that created this deserializer. Gives access to the
833833
/// context, such as list of fields, that current map known about.
834-
map: &'m mut MapAccess<'de, 'a, R, E>,
834+
map: &'m mut ElementMapAccess<'de, 'a, R, E>,
835835
}
836836

837837
impl<'de, 'a, 'm, R, E> SeqItemDeserializer<'de, 'a, 'm, R, E>

src/de/mod.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1964,6 +1964,7 @@ pub use crate::errors::serialize::DeError;
19641964
pub use resolver::{EntityResolver, NoEntityResolver};
19651965

19661966
use crate::{
1967+
de::map::ElementMapAccess,
19671968
encoding::Decoder,
19681969
errors::Error,
19691970
events::{BytesCData, BytesEnd, BytesStart, BytesText, Event},
@@ -2786,7 +2787,7 @@ where
27862787
match self.next()? {
27872788
DeEvent::Start(e) => {
27882789
let name = e.name().as_ref().to_vec();
2789-
let map = map::MapAccess::new(self, e, fields)?;
2790+
let map = ElementMapAccess::new(self, e, fields)?;
27902791
let value = visitor.visit_map(map)?;
27912792
self.read_to_end(QName(&name))?;
27922793
Ok(value)

0 commit comments

Comments
 (0)