Skip to content

Commit 2a83f8b

Browse files
authored
expose Extensions::into_http and Status::from_error (#1067)
1 parent 523a550 commit 2a83f8b

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

tonic/src/extensions.rs

+3-1
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ use std::fmt;
77
///
88
/// [`Interceptor`]: crate::service::Interceptor
99
/// [`Request`]: crate::Request
10+
#[derive(Default)]
1011
pub struct Extensions {
1112
inner: http::Extensions,
1213
}
@@ -58,8 +59,9 @@ impl Extensions {
5859
Self { inner: http }
5960
}
6061

62+
/// Convert to `http::Extensions` and consume self.
6163
#[inline]
62-
pub(crate) fn into_http(self) -> http::Extensions {
64+
pub fn into_http(self) -> http::Extensions {
6365
self.inner
6466
}
6567
}

tonic/src/status.rs

+5-1
Original file line numberDiff line numberDiff line change
@@ -310,8 +310,12 @@ impl Status {
310310
Self::from_error(err.into())
311311
}
312312

313+
/// Create a `Status` from various types of `Error`.
314+
///
315+
/// Inspects the error source chain for recognizable errors, including statuses, HTTP2, and
316+
/// hyper, and attempts to maps them to a `Status`, or else returns an Unknown `Status`.
313317
#[cfg_attr(not(feature = "transport"), allow(dead_code))]
314-
pub(crate) fn from_error(err: Box<dyn Error + Send + Sync + 'static>) -> Status {
318+
pub fn from_error(err: Box<dyn Error + Send + Sync + 'static>) -> Status {
315319
Status::try_from_error(err).unwrap_or_else(|err| {
316320
let mut status = Status::new(Code::Unknown, err.to_string());
317321
status.source = Some(err);

0 commit comments

Comments
 (0)