Skip to content

Conversation

@Aderinom
Copy link

Related Issues:

Additions:

  • Connection::try_send_datagram and Connection::try_read_datagram, returning WouldBlock when the operation cannot complete immediately
  • Connection::datagram_readable, resolving as soon as any datagram is readable
  • Connection::datagram_sendable, resolving as soon as a specified number of bytes are writable

Copy link
Collaborator

@Ralith Ralith left a comment

Choose a reason for hiding this comment

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

Per discussion in #2351, it's not clear what the try_ methods add. I don't want to maintain two copies of every single async function when it's straightforward enough to poll the futures we already have.

If you're not comfortable relying on that without a documented guarantee, feel free to propose some documentation, as @djc suggested. It would be very strange for any future that could complete immediately to return Pending instead, but I don't mind explicitly committing not to.

/// Attempts to receive an application datagram
///
/// If there are no readable datagrams, this will return [TryReceiveDatagramError::WouldBlock]
pub fn try_read_datagram(&self) -> Result<Bytes, TryReceiveDatagramError> {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Result<Option<Bytes>, ConnectionError> seems much less error-prone, since it separates the exceptional case.

Ok(())
}

/// Sets the send_blocked flag to true
Copy link
Collaborator

Choose a reason for hiding this comment

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

The send_blocked flag is not part of the public API, so this is not helpful documentation. Maybe try an imperative phrasing of what you wrote just below?

}
}

/// Creates a future, resolving as soon as a readable datagram is buffered
Copy link
Collaborator

Choose a reason for hiding this comment

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

Don't prefix async function documentation with "Creates a future"; it doesn't add information.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants