tower_grpc/server/
unimplemented.rs1use crate::{Code, Status};
2
3use futures::{Future, Poll};
4use http::header;
5
6#[derive(Debug)]
7pub struct ResponseFuture {
8 status: Option<Status>,
9}
10
11impl ResponseFuture {
12 pub(crate) fn new(msg: String) -> Self {
13 ResponseFuture {
14 status: Some(Status::new(Code::Unimplemented, msg)),
15 }
16 }
17}
18
19impl Future for ResponseFuture {
20 type Item = http::Response<()>;
21 type Error = crate::error::Never;
22
23 fn poll(&mut self) -> Poll<Self::Item, Self::Error> {
24 let status = self.status.take().expect("polled after complete");
25
26 let mut response = http::Response::new(());
28
29 response.headers_mut().insert(
34 header::CONTENT_TYPE,
35 header::HeaderValue::from_static("application/grpc"),
36 );
37
38 status
39 .add_header(response.headers_mut())
40 .expect("generated unimplemented message should be valid");
41 Ok(response.into())
42 }
43}