Skip to content

Commit

Permalink
doc: document new resource id generator
Browse files Browse the repository at this point in the history
  • Loading branch information
dr-orlovsky committed Jan 4, 2024
1 parent e337475 commit 5fbdfeb
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/resource.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ pub enum Io {
Write,
}

/// Generator for the new [`ResourceId`]s which should be used by pollers implementing [`Poll`]
/// trait.
#[derive(Copy, Clone, Ord, PartialOrd, Eq, PartialEq, Hash, Debug, Display)]
#[display(inner)]
pub struct ResourceIdGenerator(u64);
Expand All @@ -48,6 +50,7 @@ impl Default for ResourceIdGenerator {

#[allow(dead_code)] // We need this before we've got non-popol implementations
impl ResourceIdGenerator {
/// Returns the next id for the resource.
pub fn next(&mut self) -> ResourceId {
let id = self.0;
self.0 += 1;
Expand All @@ -62,6 +65,7 @@ impl ResourceIdGenerator {
pub struct ResourceId(u64);

impl ResourceId {
/// Resource id for the waker (always zero).
pub const WAKER: ResourceId = ResourceId(0);
}

Expand Down

0 comments on commit 5fbdfeb

Please sign in to comment.