@@ -137,8 +137,8 @@ impl<T: 'static + Send + Sync + Any> From<BufferKey<T>> for AnyBufferKey {
137
137
}
138
138
}
139
139
140
- /// Similar to [`BufferMut`][crate::BufferMut], but this can be unlocked with a
141
- /// [`DynBufferKey `], so it can work for any buffer regardless of the data type
140
+ /// Similar to [`BufferMut`][crate::BufferMut], but this can be unlocked with an
141
+ /// [`AnyBufferKey `], so it can work for any buffer regardless of the data type
142
142
/// inside.
143
143
pub struct AnyBufferMut < ' w , ' s , ' a > {
144
144
storage : Box < dyn AnyBufferManagement + ' a > ,
@@ -159,18 +159,18 @@ impl<'w, 's, 'a> AnyBufferMut<'w, 's, 'a> {
159
159
self
160
160
}
161
161
162
- /// Look at the oldest item in the buffer.
162
+ /// Look at the oldest message in the buffer.
163
163
pub fn oldest ( & self ) -> Option < AnyMessageRef < ' _ > > {
164
164
self . storage . any_oldest ( self . session )
165
165
}
166
166
167
- /// Look at the newest item in the buffer.
167
+ /// Look at the newest message in the buffer.
168
168
pub fn newest ( & self ) -> Option < AnyMessageRef < ' _ > > {
169
169
self . storage . any_newest ( self . session )
170
170
}
171
171
172
- /// Borrow an item from the buffer. Index 0 is the oldest item in the buffer
173
- /// with the highest index being the newest item in the buffer.
172
+ /// Borrow a message from the buffer. Index 0 is the oldest message in the buffer
173
+ /// with the highest index being the newest message in the buffer.
174
174
pub fn get ( & self , index : usize ) -> Option < AnyMessageRef < ' _ > > {
175
175
self . storage . any_get ( self . session , index)
176
176
}
@@ -194,39 +194,40 @@ impl<'w, 's, 'a> AnyBufferMut<'w, 's, 'a> {
194
194
. unwrap_or ( Gate :: Open )
195
195
}
196
196
197
- /// Modify the oldest item in the buffer.
197
+ /// Modify the oldest message in the buffer.
198
198
pub fn oldest_mut ( & mut self ) -> Option < AnyMessageMut < ' _ > > {
199
199
self . modified = true ;
200
200
self . storage . any_oldest_mut ( self . session )
201
201
}
202
202
203
- /// Modify the newest item in the buffer.
203
+ /// Modify the newest message in the buffer.
204
204
pub fn newest_mut ( & mut self ) -> Option < AnyMessageMut < ' _ > > {
205
205
self . modified = true ;
206
206
self . storage . any_newest_mut ( self . session )
207
207
}
208
208
209
- /// Modify an item in the buffer. Index 0 is the oldest item in the buffer
210
- /// with the highest index being the newest item in the buffer.
209
+ /// Modify a message in the buffer. Index 0 is the oldest message in the buffer
210
+ /// with the highest index being the newest message in the buffer.
211
211
pub fn get_mut ( & mut self , index : usize ) -> Option < AnyMessageMut < ' _ > > {
212
212
self . modified = true ;
213
213
self . storage . any_get_mut ( self . session , index)
214
214
}
215
215
216
+ /// Drain a range of messages out of the buffer.
216
217
pub fn drain < R : RangeBounds < usize > > ( & mut self , range : R ) -> DrainAnyBuffer < ' _ > {
217
218
self . modified = true ;
218
219
DrainAnyBuffer {
219
220
interface : self . storage . any_drain ( self . session , AnyRange :: new ( range) )
220
221
}
221
222
}
222
223
223
- /// Pull the oldest item from the buffer.
224
+ /// Pull the oldest message from the buffer.
224
225
pub fn pull ( & mut self ) -> Option < AnyMessage > {
225
226
self . modified = true ;
226
227
self . storage . any_pull ( self . session )
227
228
}
228
229
229
- /// Pull the item that was most recently put into the buffer (instead of the
230
+ /// Pull the message that was most recently put into the buffer (instead of the
230
231
/// oldest, which is what [`Self::pull`] gives).
231
232
pub fn pull_newest ( & mut self ) -> Option < AnyMessage > {
232
233
self . modified = true ;
@@ -398,7 +399,7 @@ pub(crate) struct AnyRange {
398
399
}
399
400
400
401
impl AnyRange {
401
- fn new < T : std:: ops:: RangeBounds < usize > > ( range : T ) -> Self {
402
+ pub ( crate ) fn new < T : std:: ops:: RangeBounds < usize > > ( range : T ) -> Self {
402
403
AnyRange {
403
404
start_bound : range. start_bound ( ) . map ( |x| * x) ,
404
405
end_bound : range. end_bound ( ) . map ( |x| * x) ,
0 commit comments