Skip to content

Commit

Permalink
io: add get_{ref,mut} methods to AsyncFdReadyGuard and AsyncFdReadyMu…
Browse files Browse the repository at this point in the history
…tGuard. (#3807)
  • Loading branch information
brain0 committed Jun 16, 2021
1 parent 34c6a26 commit 4a93af4
Showing 1 changed file with 30 additions and 0 deletions.
30 changes: 30 additions & 0 deletions tokio/src/io/async_fd.rs
Expand Up @@ -540,6 +540,16 @@ impl<'a, Inner: AsRawFd> AsyncFdReadyGuard<'a, Inner> {
result => Ok(result),
}
}

/// Returns a shared reference to the inner [`AsyncFd`].
pub fn get_ref(&self) -> &AsyncFd<Inner> {
self.async_fd
}

/// Returns a shared reference to the backing object of the inner [`AsyncFd`].
pub fn get_inner(&self) -> &Inner {
self.get_ref().get_ref()
}
}

impl<'a, Inner: AsRawFd> AsyncFdReadyMutGuard<'a, Inner> {
Expand Down Expand Up @@ -601,6 +611,26 @@ impl<'a, Inner: AsRawFd> AsyncFdReadyMutGuard<'a, Inner> {
result => Ok(result),
}
}

/// Returns a shared reference to the inner [`AsyncFd`].
pub fn get_ref(&self) -> &AsyncFd<Inner> {
self.async_fd
}

/// Returns a mutable reference to the inner [`AsyncFd`].
pub fn get_mut(&mut self) -> &mut AsyncFd<Inner> {
self.async_fd
}

/// Returns a shared reference to the backing object of the inner [`AsyncFd`].
pub fn get_inner(&self) -> &Inner {
self.get_ref().get_ref()
}

/// Returns a mutable reference to the backing object of the inner [`AsyncFd`].
pub fn get_inner_mut(&mut self) -> &mut Inner {
self.get_mut().get_mut()
}
}

impl<'a, T: std::fmt::Debug + AsRawFd> std::fmt::Debug for AsyncFdReadyGuard<'a, T> {
Expand Down

0 comments on commit 4a93af4

Please sign in to comment.