12
12
//!
13
13
//! # The raw API
14
14
//!
15
- //! The raw API consists of the `RawWorkItem` trait, where the work item needs to provide an
15
+ //! The raw API consists of the [ `RawWorkItem`] trait, where the work item needs to provide an
16
16
//! arbitrary function that knows how to enqueue the work item. It should usually not be used
17
17
//! directly, but if you want to, you can use it without using the pieces from the safe API.
18
18
//!
19
19
//! # The safe API
20
20
//!
21
- //! The safe API is used via the `Work` struct and `WorkItem` traits. Furthermore, it also includes
22
- //! a trait called `WorkItemPointer`, which is usually not used directly by the user.
21
+ //! The safe API is used via the [ `Work`] struct and [ `WorkItem`] traits. Furthermore, it also
22
+ //! includes a trait called [ `WorkItemPointer`] , which is usually not used directly by the user.
23
23
//!
24
- //! * The `Work` struct is the Rust wrapper for the C `work_struct` type.
25
- //! * The `WorkItem` trait is implemented for structs that can be enqueued to a workqueue.
26
- //! * The `WorkItemPointer` trait is implemented for the pointer type that points at a something
27
- //! that implements `WorkItem`.
24
+ //! * The [ `Work`] struct is the Rust wrapper for the C `work_struct` type.
25
+ //! * The [ `WorkItem`] trait is implemented for structs that can be enqueued to a workqueue.
26
+ //! * The [ `WorkItemPointer`] trait is implemented for the pointer type that points at a something
27
+ //! that implements [ `WorkItem`] .
28
28
//!
29
29
//! ## Example
30
30
//!
@@ -218,7 +218,9 @@ impl Queue {
218
218
}
219
219
}
220
220
221
- /// A helper type used in `try_spawn`.
221
+ /// A helper type used in [`try_spawn`].
222
+ ///
223
+ /// [`try_spawn`]: Queue::try_spawn
222
224
#[ pin_data]
223
225
struct ClosureWork < T > {
224
226
#[ pin]
@@ -258,9 +260,11 @@ impl<T: FnOnce()> WorkItem for ClosureWork<T> {
258
260
///
259
261
/// # Safety
260
262
///
261
- /// Implementers must ensure that any pointers passed to a `queue_work_on` closure by `__enqueue`
263
+ /// Implementers must ensure that any pointers passed to a `queue_work_on` closure by [ `__enqueue`]
262
264
/// remain valid for the duration specified in the guarantees section of the documentation for
263
- /// `__enqueue`.
265
+ /// [`__enqueue`].
266
+ ///
267
+ /// [`__enqueue`]: RawWorkItem::__enqueue
264
268
pub unsafe trait RawWorkItem < const ID : u64 > {
265
269
/// The return type of [`Queue::enqueue`].
266
270
type EnqueueOutput ;
@@ -290,10 +294,11 @@ pub unsafe trait RawWorkItem<const ID: u64> {
290
294
291
295
/// Defines the method that should be called directly when a work item is executed.
292
296
///
293
- /// This trait is implemented by `Pin<Box<T>>` and `Arc<T>`, and is mainly intended to be
297
+ /// This trait is implemented by `Pin<Box<T>>` and [ `Arc<T>`] , and is mainly intended to be
294
298
/// implemented for smart pointer types. For your own structs, you would implement [`WorkItem`]
295
- /// instead. The `run` method on this trait will usually just perform the appropriate
296
- /// `container_of` translation and then call into the `run` method from the [`WorkItem`] trait.
299
+ /// instead. The [`run`] method on this trait will usually just perform the appropriate
300
+ /// `container_of` translation and then call into the [`run`][WorkItem::run] method from the
301
+ /// [`WorkItem`] trait.
297
302
///
298
303
/// This trait is used when the `work_struct` field is defined using the [`Work`] helper.
299
304
///
@@ -309,8 +314,10 @@ pub unsafe trait WorkItemPointer<const ID: u64>: RawWorkItem<ID> {
309
314
///
310
315
/// # Safety
311
316
///
312
- /// The provided `work_struct` pointer must originate from a previous call to `__enqueue` where
313
- /// the `queue_work_on` closure returned true, and the pointer must still be valid.
317
+ /// The provided `work_struct` pointer must originate from a previous call to [`__enqueue`]
318
+ /// where the `queue_work_on` closure returned true, and the pointer must still be valid.
319
+ ///
320
+ /// [`__enqueue`]: RawWorkItem::__enqueue
314
321
unsafe extern "C" fn run ( ptr : * mut bindings:: work_struct ) ;
315
322
}
316
323
@@ -328,12 +335,14 @@ pub trait WorkItem<const ID: u64 = 0> {
328
335
329
336
/// Links for a work item.
330
337
///
331
- /// This struct contains a function pointer to the `run` function from the [`WorkItemPointer`]
338
+ /// This struct contains a function pointer to the [ `run`] function from the [`WorkItemPointer`]
332
339
/// trait, and defines the linked list pointers necessary to enqueue a work item in a workqueue.
333
340
///
334
341
/// Wraps the kernel's C `struct work_struct`.
335
342
///
336
343
/// This is a helper type used to associate a `work_struct` with the [`WorkItem`] that uses it.
344
+ ///
345
+ /// [`run`]: WorkItemPointer::run
337
346
#[ repr( transparent) ]
338
347
pub struct Work < T : ?Sized , const ID : u64 = 0 > {
339
348
work : Opaque < bindings:: work_struct > ,
@@ -409,7 +418,7 @@ impl<T: ?Sized, const ID: u64> Work<T, ID> {
409
418
/// }
410
419
/// ```
411
420
///
412
- /// Note that since the `Work` type is annotated with an id, you can have several `work_struct`
421
+ /// Note that since the [ `Work`] type is annotated with an id, you can have several `work_struct`
413
422
/// fields by using a different id for each one.
414
423
///
415
424
/// # Safety
@@ -429,7 +438,7 @@ pub unsafe trait HasWork<T, const ID: u64 = 0> {
429
438
/// Returns the offset of the [`Work<T, ID>`] field.
430
439
///
431
440
/// This method exists because the [`OFFSET`] constant cannot be accessed if the type is not
432
- /// `Sized`.
441
+ /// [ `Sized`] .
433
442
///
434
443
/// [`Work<T, ID>`]: Work
435
444
/// [`OFFSET`]: HasWork::OFFSET
0 commit comments