Browse Source

Document block.rs

Johannes Hofmann 8 years ago
parent
commit
e9da933893
1 changed files with 17 additions and 2 deletions
  1. 17
    2
      src/block.rs

+ 17
- 2
src/block.rs View File

1
-//! `HeaderBlock`, `PrimitiveBlock` and `Group`s
1
+//! `HeaderBlock`, `PrimitiveBlock` and `PrimitiveGroup`s
2
 
2
 
3
 use dense::DenseNodeIter;
3
 use dense::DenseNodeIter;
4
 use elements::{Node, Way, Relation};
4
 use elements::{Node, Way, Relation};
7
 use std;
7
 use std;
8
 
8
 
9
 
9
 
10
+/// A `HeaderBlock`. It contains metadata about following `PrimitiveBlock`s.
10
 pub struct HeaderBlock {
11
 pub struct HeaderBlock {
11
     header: osmformat::HeaderBlock,
12
     header: osmformat::HeaderBlock,
12
 }
13
 }
16
         HeaderBlock { header: header }
17
         HeaderBlock { header: header }
17
     }
18
     }
18
 
19
 
20
+    /// Returns a list of required features that a parser needs to implement to parse the following
21
+    /// `PrimitiveBlock`s.
19
     pub fn required_features(&self) -> &[String] {
22
     pub fn required_features(&self) -> &[String] {
20
         self.header.get_required_features()
23
         self.header.get_required_features()
21
     }
24
     }
22
 
25
 
26
+    /// Returns a list of optional features that a parser can choose to ignore.
23
     pub fn optional_features(&self) -> &[String] {
27
     pub fn optional_features(&self) -> &[String] {
24
         self.header.get_optional_features()
28
         self.header.get_optional_features()
25
     }
29
     }
26
 }
30
 }
27
 
31
 
32
+/// A `PrimitiveBlock`. It contains a sequence of groups.
28
 pub struct PrimitiveBlock {
33
 pub struct PrimitiveBlock {
29
     block: osmformat::PrimitiveBlock,
34
     block: osmformat::PrimitiveBlock,
30
 }
35
 }
31
 
36
 
32
 impl PrimitiveBlock {
37
 impl PrimitiveBlock {
33
-    pub fn new(block: osmformat::PrimitiveBlock) -> PrimitiveBlock {
38
+    pub(crate) fn new(block: osmformat::PrimitiveBlock) -> PrimitiveBlock {
34
         PrimitiveBlock { block: block }
39
         PrimitiveBlock { block: block }
35
     }
40
     }
36
 
41
 
42
+    /// Returns an iterator over the groups in this `PrimitiveBlock`.
37
     pub fn groups(&self) -> GroupIter {
43
     pub fn groups(&self) -> GroupIter {
38
         GroupIter::new(&self.block)
44
         GroupIter::new(&self.block)
39
     }
45
     }
40
 }
46
 }
41
 
47
 
48
+/// A `PrimitiveGroup` contains a sequence of elements of one type.
42
 pub struct PrimitiveGroup<'a> {
49
 pub struct PrimitiveGroup<'a> {
43
     block: &'a osmformat::PrimitiveBlock,
50
     block: &'a osmformat::PrimitiveBlock,
44
     group: &'a osmformat::PrimitiveGroup,
51
     group: &'a osmformat::PrimitiveGroup,
54
         }
61
         }
55
     }
62
     }
56
 
63
 
64
+    /// Returns an iterator over the nodes in this group.
57
     pub fn nodes(&self) -> GroupNodeIter<'a> {
65
     pub fn nodes(&self) -> GroupNodeIter<'a> {
58
         GroupNodeIter::new(self.block, self.group)
66
         GroupNodeIter::new(self.block, self.group)
59
     }
67
     }
60
 
68
 
69
+    /// Returns an iterator over the dense nodes in this group.
61
     pub fn dense_nodes(&self) -> DenseNodeIter<'a> {
70
     pub fn dense_nodes(&self) -> DenseNodeIter<'a> {
62
         DenseNodeIter::new(self.block, self.group.get_dense())
71
         DenseNodeIter::new(self.block, self.group.get_dense())
63
     }
72
     }
64
 
73
 
74
+    /// Returns an iterator over the ways in this group.
65
     pub fn ways(&self) -> GroupWayIter<'a> {
75
     pub fn ways(&self) -> GroupWayIter<'a> {
66
         GroupWayIter::new(self.block, self.group)
76
         GroupWayIter::new(self.block, self.group)
67
     }
77
     }
68
 
78
 
79
+    /// Returns an iterator over the relations in this group.
69
     pub fn relations(&self) -> GroupRelationIter<'a> {
80
     pub fn relations(&self) -> GroupRelationIter<'a> {
70
         GroupRelationIter::new(self.block, self.group)
81
         GroupRelationIter::new(self.block, self.group)
71
     }
82
     }
72
 }
83
 }
73
 
84
 
85
+/// An iterator over the groups in a `PrimitiveBlock`.
74
 pub struct GroupIter<'a> {
86
 pub struct GroupIter<'a> {
75
     block: &'a osmformat::PrimitiveBlock,
87
     block: &'a osmformat::PrimitiveBlock,
76
     groups: std::slice::Iter<'a, osmformat::PrimitiveGroup>,
88
     groups: std::slice::Iter<'a, osmformat::PrimitiveGroup>,
102
 
114
 
103
 impl<'a> ExactSizeIterator for GroupIter<'a> {}
115
 impl<'a> ExactSizeIterator for GroupIter<'a> {}
104
 
116
 
117
+/// An iterator over the nodes in a `Group`.
105
 pub struct GroupNodeIter<'a> {
118
 pub struct GroupNodeIter<'a> {
106
     block: &'a osmformat::PrimitiveBlock,
119
     block: &'a osmformat::PrimitiveBlock,
107
     nodes: std::slice::Iter<'a, osmformat::Node>,
120
     nodes: std::slice::Iter<'a, osmformat::Node>,
135
 
148
 
136
 impl<'a> ExactSizeIterator for GroupNodeIter<'a> {}
149
 impl<'a> ExactSizeIterator for GroupNodeIter<'a> {}
137
 
150
 
151
+/// An iterator over the ways in a `Group`.
138
 pub struct GroupWayIter<'a> {
152
 pub struct GroupWayIter<'a> {
139
     block: &'a osmformat::PrimitiveBlock,
153
     block: &'a osmformat::PrimitiveBlock,
140
     ways: std::slice::Iter<'a, osmformat::Way>,
154
     ways: std::slice::Iter<'a, osmformat::Way>,
168
 
182
 
169
 impl<'a> ExactSizeIterator for GroupWayIter<'a> {}
183
 impl<'a> ExactSizeIterator for GroupWayIter<'a> {}
170
 
184
 
185
+/// An iterator over the relations in a `Group`.
171
 pub struct GroupRelationIter<'a> {
186
 pub struct GroupRelationIter<'a> {
172
     block: &'a osmformat::PrimitiveBlock,
187
     block: &'a osmformat::PrimitiveBlock,
173
     rels: std::slice::Iter<'a, osmformat::Relation>,
188
     rels: std::slice::Iter<'a, osmformat::Relation>,