Skip to content
This repository has been archived by the owner on May 18, 2022. It is now read-only.

Add accessors to Consume #148

Merged
merged 4 commits into from
Aug 14, 2020
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions rubble/src/link/queue.rs
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,21 @@ impl<T> Consume<T> {
result,
}
}

/// Retrieves whether this consume represents consuming a packet or not.
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
/// Retrieves whether this consume represents consuming a packet or not.
/// Retrieves whether the packet should be removed from the queue.

pub fn consume(&self) -> bool {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe should_consume would be better? Feel free to rename the field to match as well.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Renamed!

self.consume
}

/// Retrieves a reference to the inner result.
pub fn result(&self) -> &Result<T, Error> {
&self.result
}

/// Unwraps this [`Consume`], retrieving the inner result.
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The link doesn't go anywhere

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right. I'm not entirely sure what I was thinking with this, thanks for catching it!

pub fn into_result(self) -> Result<T, Error> {
self.result
}
}

/// A simple packet queue that can hold a single packet.
Expand Down