Skip to content

Commit 866ec3b

Browse files
author
Danilo Krummrich
committed
rust: page: define trait AsPageIter
The AsPageIter trait provides a common interface for types that provide a page iterator, such as VmallocPageIter. Subsequent patches will leverage this to let VBox and VVec provide a VmallocPageIter though this trait. Reviewed-by: Alice Ryhl <aliceryhl@google.com> Reviewed-by: Alexandre Courbot <acourbot@nvidia.com> Tested-by: Alexandre Courbot <acourbot@nvidia.com> Reviewed-by: Daniel Almeida <daniel.almeida@collabora.com> Link: https://lore.kernel.org/r/20250820145434.94745-5-dakr@kernel.org Signed-off-by: Danilo Krummrich <dakr@kernel.org>
1 parent 7937dca commit 866ec3b

1 file changed

Lines changed: 12 additions & 0 deletions

File tree

rust/kernel/page.rs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,18 @@ impl<'a> Deref for BorrowedPage<'a> {
103103
}
104104
}
105105

106+
/// Trait to be implemented by types which provide an [`Iterator`] implementation of
107+
/// [`BorrowedPage`] items, such as [`VmallocPageIter`](kernel::alloc::allocator::VmallocPageIter).
108+
pub trait AsPageIter {
109+
/// The [`Iterator`] type, e.g. [`VmallocPageIter`](kernel::alloc::allocator::VmallocPageIter).
110+
type Iter<'a>: Iterator<Item = BorrowedPage<'a>>
111+
where
112+
Self: 'a;
113+
114+
/// Returns an [`Iterator`] of [`BorrowedPage`] items over all pages owned by `self`.
115+
fn page_iter(&mut self) -> Self::Iter<'_>;
116+
}
117+
106118
/// A pointer to a page that owns the page allocation.
107119
///
108120
/// # Invariants

0 commit comments

Comments
 (0)