@@ -192,16 +192,51 @@ impl<'a, M: GuestMemory, T: RingAccess> SplitQueueRing<'a, M, T> {
192
192
. checked_add ( self . ring . len as GuestUsize )
193
193
. unwrap ( )
194
194
}
195
+
196
+ /// Load the value of the `flags` field.
197
+ pub fn load_flags ( & self ) -> u16 {
198
+ u16:: from_le ( self . flags . load ( ) )
199
+ }
200
+
201
+ /// Store the `flags` field.
202
+ pub fn store_flags ( & self , val : u16 ) {
203
+ self . flags . store ( u16:: to_le ( val) )
204
+ }
205
+
206
+ /// Load the value of the `idx` field.
207
+ pub fn load_idx ( & self ) -> u16 {
208
+ u16:: from_le ( self . idx . load ( ) )
209
+ }
210
+
211
+ /// Store the `idx` field.
212
+ pub fn store_idx ( & self , val : u16 ) {
213
+ self . idx . store ( u16:: to_le ( val) )
214
+ }
215
+
216
+ /// Load a ring entry at `index`.
217
+ pub fn load_ring_entry ( & self , index : usize ) -> Result < T , MockError > {
218
+ self . ring
219
+ . ref_at ( index)
220
+ . map ( |r| T :: from_le ( r. load ( ) ) )
221
+ }
222
+
223
+ /// Store a ring entry at `index`.
224
+ pub fn store_ring_entry ( & self , index : usize , val : T ) -> Result < ( ) , MockError > {
225
+ self . ring
226
+ . ref_at ( index)
227
+ . map ( |r| r. store ( val. to_le ( ) ) )
228
+ }
195
229
196
- /// Return a reference to the idx field.
197
- pub fn idx ( & self ) -> & Ref < ' a , M , u16 > {
198
- & self . idx
230
+ /// Load the value of the event field.
231
+ pub fn load_event ( & self ) -> u16 {
232
+ u16 :: from_le ( self . event . load ( ) )
199
233
}
200
234
201
- /// Return a reference to the ring field.
202
- pub fn ring ( & self ) -> & ArrayRef < ' a , M , T > {
203
- & self . ring
235
+ /// Store the event field.
236
+ pub fn store_event ( & self , val : u16 ) {
237
+ self . event . store ( u16 :: to_le ( val ) )
204
238
}
239
+
205
240
}
206
241
207
242
/// The available ring is used by the driver to offer buffers to the device.
0 commit comments