tonic/
codegen.rs

1//! Codegen exports used by `tonic-build`.
2
3pub use async_trait::async_trait;
4pub use futures_core;
5pub use futures_util::future::{ok, poll_fn, Ready};
6
7pub use std::future::Future;
8pub use std::pin::Pin;
9pub use std::sync::Arc;
10pub use std::task::{Context, Poll};
11pub use tower_service::Service;
12pub type StdError = Box<dyn std::error::Error + Send + Sync + 'static>;
13#[cfg(feature = "compression")]
14pub use crate::codec::{CompressionEncoding, EnabledCompressionEncodings};
15pub use crate::service::interceptor::InterceptedService;
16pub use http_body::Body;
17
18pub type BoxFuture<T, E> = self::Pin<Box<dyn self::Future<Output = Result<T, E>> + Send + 'static>>;
19pub type BoxStream<T> =
20    self::Pin<Box<dyn futures_core::Stream<Item = Result<T, crate::Status>> + Send + 'static>>;
21
22pub mod http {
23    pub use http::*;
24}
25
26#[derive(Debug)]
27pub enum Never {}
28
29impl std::fmt::Display for Never {
30    fn fmt(&self, _: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
31        match *self {}
32    }
33}
34
35impl std::error::Error for Never {}
36
37pub fn empty_body() -> crate::body::BoxBody {
38    http_body::Empty::new()
39        .map_err(|err| match err {})
40        .boxed_unsync()
41}