Skip to content

Commit 03fd6af

Browse files
authored
feat(client): add a TrySendError::message() method (#3884)
this commit introduces a new inherent method to `hyper::client::conn::TrySendError<T>`. this error type includes a `TrySendError::take_message()` method today that will return an owned instance of the inbound message, should the underlying dispatch have been closed before serialization of the message ever began. this commit introduces a new method that allows callers to inspect the message, e.g. to update metrics, without needing to take ownership of the message. Signed-off-by: katelyn martin <[email protected]>
1 parent 12d9b55 commit 03fd6af

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

src/client/dispatch.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -304,6 +304,15 @@ impl<T> TrySendError<T> {
304304
self.message.take()
305305
}
306306

307+
/// Returns a reference to the recovered message.
308+
///
309+
/// The message will not always have been recovered. If an error occurs
310+
/// after the message has been serialized onto the connection, it will not
311+
/// be available here.
312+
pub fn message(&self) -> Option<&T> {
313+
self.message.as_ref()
314+
}
315+
307316
/// Consumes this to return the inner error.
308317
pub fn into_error(self) -> crate::Error {
309318
self.error

0 commit comments

Comments
 (0)